I know that it\'s a common convention to pass the length of dynamically allocated arrays to functions that manipulate them:
void initializeAndFree(int* anArr
You can't get it because the C committee did not require that in the standard.
If you are willing to write some non-portable code, you may have luck with:
*((size_t *)ptr - 1)
or maybe:
*((size_t *)ptr - 2)
But whether that works will depend on exactly where the implementation of malloc you are using stores that data.