On Thu, 7 Sep 2000, Caolan McNamara wrote:
> You know if linux is always going to overcommit memory so that the
> malloc family never returns NULL then maybe gcc should have an
> optimization option to prune execution branches that rely on their
> failure.
>
be kinda a hard thing to pick up with a translation schema of any sort
because people check NULL values in different ways. Not impossible, I can
see how it might be done, it would just look weird
> I know of course that you'd be mad to use the option, especially to
> create binaries to give to others who might have overcommittment
> turned off now or in the future, but it would be amusing to see what
> sort of a difference it makes size/speed wise (not a lot Id guess,
> but could be fun)
>> Possibly already supported in some form or other ?
>
hmmm. Macros I would imagine. Something less ugly (too early to think of
something nice) than this off the top of my head
#ifdef MALLOC_NONULLCHECK
#define MALLOC(TYPE, VAR, SIZE) VAR = (TYPE)malloc(sizeof(TYPE) * SIZE);
#else
#define MALLOC(TYPE, VAR, SIZE) if (VAR = (TYPE)malloc((sizeof(TYPE) * SIZE) == NULL) { exit(-1); }
#endif
Write a test program and compile it with MALLOC_NONULLCHECK defined and
then undefined, lamp through time a couple of times and see if there is
any increase.
Mel
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!