Re: How does free() know how many bytes to free???
- From: phil-news-nospam@xxxxxxxx
- Date: 27 Nov 2007 16:36:14 GMT
On Tue, 27 Nov 2007 06:43:20 -0800 Paul Pluzhnikov <ppluzhnikov-nsp@xxxxxxxxxxx> wrote:
| The malloc implementation inside glibc is not very easy to
| understand, because it is "production" code, optimized for speed,
| multi-threaded access, etc.
A great deal of code in the world is "production" code, or at the very
least, code that has moved beyond being an example or proof of concept.
Almost all of the kernel and libraries are poor examples of how to do
a conceptual algorithm implementation. "production code" is far more
than just an implementation of some algorithm; it is also how that
algorithm is applied in a particular context. Even when something is
organized well so algorithms are encapsulated, it is still not teaching
quality, at least for beginners.
I just wish fewer people would fallback on the tiresome old "read the
source code".
| A much simpler implementation can be found in K&R (2nd edition,
| p.185) -- Chapter 8.7 Example -- A Storage Allocator.
Not having a look at this (my K&R disappeared about 10 years ago), I'd
have to guess this is better for a student to get started than just about
any production open source project. Better would be a text discussing
the issue is storage allocators in prose, with the appropriate partial
code examples in the right places.
FYI, many years ago, I found a bug in the glibc strtold() function. I
reported the bug, but it hadn't gotten fixed. Since I needed to use it,
I decided to look into the glibc source itself. That code was such a
tangled mess of references and generations, I was never able to even
figure out exactly in what source code file the bug was even happening.
So I ended up writing my own strtold() from scratch. Eventually the bug
was fixed and I abandoned by own code. Clearly, the code in glibc is
not something that can stand up as an example of _just_ an algorithm.
--
|---------------------------------------/----------------------------------|
| Phil Howard KA9WGN (ka9wgn.ham.org) / Do not send to the address below |
| first name lower case at ipal.net / spamtrap-2007-11-27-1019@xxxxxxxx |
|------------------------------------/-------------------------------------|
.
- Follow-Ups:
- Re: How does free() know how many bytes to free???
- From: Wolfgang Draxinger
- Re: How does free() know how many bytes to free???
- References:
- How does free() know how many bytes to free???
- From: MAx
- Re: How does free() know how many bytes to free???
- From: Wolfgang Draxinger
- Re: How does free() know how many bytes to free???
- From: Paul Pluzhnikov
- How does free() know how many bytes to free???
- Prev by Date: Re: new filesystem module
- Next by Date: Re: module license taints kernel.
- Previous by thread: Re: How does free() know how many bytes to free???
- Next by thread: Re: How does free() know how many bytes to free???
- Index(es):
Relevant Pages
|