I have an array of pointers to struct, and after processing the array, the pointer is at the end of the memory block. I want to free memory block, so I need to go to the first memory byte and loop through the array of pointers again to free each of the elements in the array. How would you point back to the first byte of the memory block?
Share
There isn’t an automatic way – you have to pass the original location to free.
Common techniques are to make a copy of the original pointer or if you know the number of entries and their size you can just subtract this from the pointer