Re: cc to gcc problems

Steve Lamont (spl@szechuan.ucsd.edu)
Fri, 21 Mar 97 16:08:03 PST

To subscribers of the xforms list from spl@szechuan.ucsd.edu (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.

spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/xforms-archive/