func: void *toCaps(void *data) struct stonesoup_data * stonesoupData = data ; int i ; for(i = 0; i < stonesoupData->data_size; i++) if ( stonesoupData -> data [ i ] >= 'a' && stonesoupData -> data [ i ] <= 'z' )  stonesoupData -> data [ i ] -= 'a' - 'A'; arrFunc ( stonesoupData ); void arrFunc (struct stonesoup_data *stonesoupData) int * stonesoup_arr = malloc ( sizeof ( int ) * stonesoupData -> qsize ) ; int stonesoup_i ; int stonesoup_j ; static int stonesoup_ctr ; stonesoup_ctr = 0; for(stonesoup_i = 0; /* and count twice when second thread is in func stonesoup_i < stonesoupData->data_size; /* which will blow the free() struct away stonesoup_i++, stonesoup_ctr++) stonesoupData -> data [ stonesoup_ctr ] = '\0'; if ( stonesoupData -> qsize > 5 )  for (stonesoup_j = 0; stonesoup_j < stonesoupData->qsize; stonesoup_j++) stonesoup_arr [ stonesoup_j ] = stonesoupData -> qsize - stonesoup_j; free ( stonesoup_arr ); 