I took a closer look at the code you posted; I came up with a working version, however because I am unfamiliar with your project's requirements, I may have assumed some things incorrectly.
(Btw, the one line of code that needed to be readjusted was the malloc() for the thread_info_t object).
// Function prototypes
void* dummy_enzyme(void* data);
unsigned int make_enzyme_threads(pthread_t* tids, const char* str, void *(*fp)(void*));
int main(int argc, char** argv)
const char* str = "enzymatic";
pthread_t* tids = calloc(strlen(str), sizeof(pthread_t));
unsigned int n = make_enzyme_threads(tids, str, dummy_enzyme);
void* status = 0;
for (unsigned int t = 0; t < n; ++t)
printf("%d\n", ((thread_info_t*) status)->swapcount);
void* dummy_enzyme(void* data)
thread_info_t* info = (thread_info_t*) data;
info->swapcount = info->string - 'a';
unsigned int make_enzyme_threads(pthread_t* tids, const char* str, void *(*fp)(void*))
const size_t len = strlen(str);
size_t i = 0;
for (; i < len; ++i)
thread_info_t* info = malloc(sizeof(thread_info_t));
info->string = *(str + i); // save a single character???
if (pthread_create(&(tids[i]), NULL, fp, info) != 0)
printf("error creating thread.\n");