Are you sure?
Posted Jun 30, 2011 6:19 UTC (Thu) by
cpeterso (guest, #305)
In reply to:
Are you sure? by nix
Parent article:
Zeuthen: Writing a C library, part 1
> Your approach (the second one) would have worked, if I could have revamped the entire source base to use it. But it is rare that one gets the opportunity to do that, and malloc() tests at least don't look strange.
If you're brave, there's always the C preprocessor:
#define malloc(size) my_xmalloc_with_msg(size, __FILE__, __LINE__, __FUNCTION__)
This approach could still be useful if your macro was only #included by a subset of .c files, leaving some object code still calling libc's malloc().
(
Log in to post comments)