On 24 August 2015 at 15:29, Kyle Harper wrote: > > void starting_routine(List *list) { > // Starting point a thread will use. > Buffer *local_buf_ptr; > printf("%d : Thread starting up. local_buf_ptr is currently %d, ", > pthread_self(), local_buf_ptr); > local_buf_ptr = list->pool[0]; > printf("and is now %d\n", local_buf_ptr); > break_crap(list, &local_buf_ptr); Here you pass the address of a local variable. > pthread_exit(0); > } > > > void break_crap(List *list, Buffer **buf) { > // Emulate the buffer removal. > pthread_mutex_lock(&list->lock); > printf("%d : checking to see if *buf is null\n", pthread_self()); > if (*buf == NULL) { Here you check if that local variable is null. > printf("%d : *buf is null so I'm leaving.\n", pthread_self()); > pthread_mutex_unlock(&list->lock); > return; > } > printf("%d : *buf is not null and has ID=%d and lock_id=%d, > free()ing and NULL-ing\n", pthread_self(), (*buf)->id, > (*buf)->lock_id); > free(*buf); > *buf = NULL; You are nulling the local variable, not the array element it points to.