Re: cc to gcc problems

Steve Lamont (
Fri, 21 Mar 97 16:08:03 PST

To subscribers of the xforms list from (Steve Lamont) :

> The first thing I've noticed is the difference between the cc and
> gcc versions of realloc().

I'm not sure what difference you've observed but I suspect that this
isn't gcc related but library related.

realloc() and its ilk are not defined in gcc or in libgcc.a. It
generally lives in libc.a, which is generally supplied with the OS.

The difference to which I think you may be referring is the way that
realloc() handles NULL argument. Some systems implement realloc() in
such a way as to allow to accept a NULL pointer as its first argument
and just do a malloc() and some will reward you with a core dump.

My usual tack is to do something like

int *stuff = ( int *) malloc( 1 );


stuff = ( int *) realloc( stuff, sizeof( int ) * some_stuff_count );

on any pointer that I need to grow or shrink.

To unsubscribe, send the message "unsubscribe" to or see
Xforms Home Page:
List Archive: