Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

when you do a real free(), it frees up memory for any program to use

This is an extremely naive description of not only what the libc free() function does, but also of how memory management works in general.



There are always details within details. The overall idea is easily understandable. You are being pedantic.


Your description reveals a complete lack of understanding, and pointing out someone's lack of understanding is not being pedantic. Your choice of wording—"real free()" and "any program"—misrepresents the inherent complexity of implementing an allocator and does a disservice to both those less experienced and to the discussion in this thread.


You're assuming a platform. There are not a great number of guarantees when it comes to free:

The free subroutine deallocates a block of memory previously allocated by the malloc subsystem. Undefined results occur if the Pointer parameter is not an address that has previously been allocated by the malloc subsystem, or if the Pointer parameter has already been deallocated. If the Pointer parameter is NULL, no action occurs.

All that is guaranteed, is a deallocation. Not how and when that memory will become available again.

Your "more detailed" understanding will break, and will cause headaches, on platforms ypu're not used to.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: