Re: How does free() know how many bytes to free???



Wolfgang Draxinger <wdraxinger@xxxxxxxxxxxxxxxx> writes:

MAx wrote:
....
How does free() know how many bytes to deallocate?

Have a look at the source code of your libc.

The malloc implementation inside glibc is not very easy to
understand, because it is "production" code, optimized for speed,
multi-threaded access, etc.

A much simpler implementation can be found in K&R (2nd edition,
p.185) -- Chapter 8.7 Example -- A Storage Allocator.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
.



Relevant Pages

  • Re: Stack size calculation - looking for supporting tool
    ... that scans C source code, and calculates the required stack size, ... Only plain C, no recursion. ... then nodes only calling terminals with the sum of the ... I tried this once and the use of function pointers in the code made it ...
    (comp.lang.c)
  • Re: Stack size calculation - looking for supporting tool
    ... that scans C source code, and calculates the required stack size, ... Only plain C, no recursion. ... (don't say "stack" around comp.lang.c; here, ... The only problem are function pointers. ...
    (comp.lang.c)
  • Re: Stack size calculation - looking for supporting tool
    ... that scans C source code, and calculates the required stack size, ... Only plain C, no recursion. ... then nodes only calling terminals with the sum of the ... I tried this once and the use of function pointers in the code made it ...
    (comp.lang.c)
  • Re: Stack size calculation - tool support?
    ... that scans C source code, and calculates the required tack size, based ... Only plain C, no recursion. ... Granted, an RTOS makes life difficult, but even there the stack usage of ... From the source code, you may be able to compute the depth of nesting, ...
    (comp.arch.embedded)
  • Re: how to order ld to use a specific libstdc++ version ?
    ... (Source code unavailable.) ... ignoring that warning. ... for each symbol, verify that the ABI for that symbol, and all ... In order to understand recursion you must first understand recursion. ...
    (comp.unix.programmer)