Coming back to some C code I wrote a few years ago and I feel it ought to be leaking memory, but I can find no sign that is it and I would like to check my assumptions.
I have a structure like this:
struct BitArray { .... char *bits; .... } bits is allocated dynamically like this:
bArray->bits = (char *)calloc(1, 1 << shiftNumber); And free-ed like this:
free(nextBA->bits); But shouldn't that leak memory - ie it will only free the very first char that bits points to? What is the correct way to free the memory allocated in this way?