c - How does free() know how much memory to free? -
possible duplicate:
c programming : how free know how free?
in snippet
void main() { void *p = malloc(300); printf("%d",sizeof(*p)); free(p); }
how free know memory supposed release void pointer?
i figure, if there internal table/function, should available find out sizes of kind of objects, whereas output of printf
1
malloc , free own hidden accounting can correct thing.
the reason sizeof() not use accounting information sizeof() compile time operator, , malloc/free information not available until runtime.
Comments
Post a Comment