Skip to main content
Pasted the comments from the source herein (an answer shall not just be a link)
Source Link
jdehaan
  • 19.9k
  • 6
  • 62
  • 98

From the comp.lang.c FAQ list: How does free know how many bytes to free?

The malloc/free implementation remembers the size of each block as it is allocated, so it is not necessary to remind it of the size when freeing. (Typically, the size is stored adjacent to the allocated block, which is why things usually break badly if the bounds of the allocated block are even slightly overstepped)

From the comp.lang.c FAQ list: How does free know how many bytes to free?

From the comp.lang.c FAQ list: How does free know how many bytes to free?

The malloc/free implementation remembers the size of each block as it is allocated, so it is not necessary to remind it of the size when freeing. (Typically, the size is stored adjacent to the allocated block, which is why things usually break badly if the bounds of the allocated block are even slightly overstepped)

added 38 characters in body
Source Link
Sinan Ünür
  • 118k
  • 15
  • 199
  • 343
Source Link
jdehaan
  • 19.9k
  • 6
  • 62
  • 98