Naming
Doug Gwyn
gwyn at smoke.BRL.MIL
Wed Feb 28 06:48:27 AEST 1990
In article <MCDANIEL.90Feb27103334 at amara.amara.uucp> mcdaniel at amara.uucp (Tim McDaniel) writes:
>Are standard library names utterly and completely reserved, or can I
>fake it with #define, as in
> #define malloc(bytes) my_malloc(bytes, __FILE__, __LINE__)
You may #define your own malloc macro only if you don't #include <stdlib.h>.
However, C library functions that need to allocate storage may invoke the
real malloc() library function to do so; consequently your my_malloc()
implementation had better not interfere with the standard malloc(). The
usual way to guarantee this would be for my_malloc() to obtain its own
memory pool via malloc() and reallocate portions of it according to its
own notions.
It would be better to use some name other than malloc for this macro.
More information about the Comp.std.c
mailing list