c - Free() crashes program -


when calling function b_destroy, program crashes before reaches end of function. function looks this:

void b_destroy(buffer * const pbd){ #ifdef debug printf("in destroy\n"); printf("buffer address %d\n",pbd); printf("head address %d\n",pbd->ca_head); #endif if(pbd != null || pbd->ca_head != null){     if (pbd->ca_head != null)         free(pbd->ca_head);     if (pbd != null)         free(pbd); } #ifdef debug     printf("exiting destroy\n"); #endif } 

i know pointers aren't null because i'm able print out memory location. ideas why crashes?

it doesn't matter address not null, rather data there has not been freed. need search elsewhere see if same memory has been freed, free doesn't set given pointer null afterwords.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -