Does anyone know if its possible to find the size of an variable from a pointer to the said object. I have the below code (and similar code in my_malloc, which for obvouse reasons is simpler to implement) ovcourse the below returns the size of the pointer not the object, can anyone help?
Code:
void my_free(void *ptr){
div_t temp;
if (memmoryusage == NULL){
memmoryusage = 0;
}
memmoryusage = memmoryusage - sizeof(&ptr);
temp = div( memmoryusage, 100 );
printf("(F) MEMORY = %d, %d, %d%\n", memmoryusage, sizeof(&ptr), temp.quot);
free(ptr);
}