[ILUG] Shink your code and execution speeds.
Mel
mel at csn.ul.ie
Thu Sep 7 10:37:47 IST 2000
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
More information about the ILUG
mailing list