Most certainly. I had been looking at dlmalloc(), a PD implementation of malloc() that actually formed the base for Linux' malloc() implementation for some time (still?).BI lazy wrote: @Solar: d'ya want a malloc/realloc/free library in your pdclib?
Any contribution is welcome. Even if it isn't "correct" code, working through two impelementations and coming up with the best of both is still easier than writing it up all on yourself.Mine is probably not the most sophisticated and most efficient one, but it does its job quite well - although it yet lacks hooks for semaphore locks/spinlocks around critical regions and hooks for the system call "gimme mo memory".
BTW, there's no way around that hook into the kernel - that's sbrk() for you on POSIX systems.
Amazing how far people get without having a standard at hand... You should be able to look it up in virtually every C language reference. Or try 'man calloc' on your favourite bash shell.I have not yet written a calloc (what properties does this one have?) nor do I consider my realloc a correct one (what is it expected to return upon failure?)