[comp.windows.x] X11 on HP-UX 7.0 -- what I fixed in XtRealloc

root@shawn.uucp (0000-Admin(0000)) (01/28/91)

My mailer is brain-dead, so I thought I'd post the response to inquirers
since others could benefit.

I was asked what I debugged in XtRealloc() to get X11R4 working on HP-UX 7.0:

Basically, as best as I can remember, XtRealloc() failed and printed an error
to stdout whenever it was given a size argument of zero.  As I recall,
realloc() should free the block in question at that point (at least on some 
systems).  I manually hacked XtRealloc.c so that if a size of zero was ever 
passed in, it would invoke free() on the block pointed to instead of realloc().
After that, all the Toolkit clients that were malfunctioning before began to
work correctly.

My guess is that realloc(2) had a subtle change between HP-UX 6.5 and 7.0,
since 1) X11R4 is advertised to compile "off-the-shelf" on 6.5 and
2) everything else seems just fine on 7.0.

harry@hpcvlx.cv.hp.com (Harry Phinney) (01/30/91)

root@shawn.uucp writes:
> My guess is that realloc(2) had a subtle change between HP-UX 6.5 and 7.0,
> since 1) X11R4 is advertised to compile "off-the-shelf" on 6.5 and
> 2) everything else seems just fine on 7.0.

It depends on which malloc() package is used.  The malloc/realloc in
libc.a will return a valid pointer when asked to allocate 0 bytes.  The
malloc/realloc in libmalloc.a(3x) will return NULL when asked to
allocate 0 bytes.  If you are linking with libmalloc.a, then you need to
define MALLOC_0_RETURNS_NULL in the StandardDefines in the hp.cf file in
$(TOP)/config.  There's no need to hack the library code.

Harry Phinney   harry@hp-pcd.cv.hp.com