Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!samsung!munnari.oz.au!uhccux!quonset!jwright From: jwright@cfht.hawaii.edu (Jim Wright) Newsgroups: comp.sys.hp Subject: Re: X11R4: Problem executing xgc(demo) and xrn6.8(comp.sources.x) Message-ID: Date: 4 Aug 90 06:39:43 GMT References: <2297@s3.ireq.hydro.qc.ca> Sender: news@uhccux.uhcc.Hawaii.Edu Lines: 47 lamarche@ireq.hydro.qc.ca writes: >I have compiled X11R4 (original tapes) on my hp360 machine >running HP-UX 7.0. Everything went fine. Then I compiled >xrn (6.8) from comp.sources.x, everything went fine also. >When I run xgc ( in mit/demo ) or xrn both programs abort. >I get the message: > Error: Cannot perform realloc >Does anyone have an idea of a solution to this problem? I was able to beat this same bug, with lots of email help from some folks at HP. (Sorry, can't find names right now.) The "problem" is that X may call one of the alloc() routines with a request for zero bytes of memory, but expects to get a valid pointer back. I consider this a bug in X and not in HP's alloc. To fix this, you have to define the pre-processor symbol MALLOC_0_RETURNS_NULL and recompile *ALL* of X as well as all of your applications. This worked wonders for me. Below are a bits from two pertinent files. /*---------------- extract from site.def file ----------------*/ STD_DEFINES = -Wc,-Nd4000,-Ns3000 -DMALLOC_0_RETURNS_NULL -DSYSV /*---------------- extract from X11/Xlibos.h -----------------*/ /*** char *malloc(), *realloc(), *calloc(), *alloca(); *** FIXED - jrw ***/ void *malloc(), *realloc(), *calloc(), *alloca(); /* * Note that some machines do not return a valid pointer for malloc(0), in * which case we provide an alternate under the control of the * define MALLOC_0_RETURNS_NULL. This is necessary because some * Xlib code expects malloc(0) to return a valid pointer to storage. */ #ifdef MALLOC_0_RETURNS_NULL # define Xmalloc(size) malloc(((size) > 0 ? (size) : 1)) # define Xrealloc(ptr, size) realloc((ptr), ((size) > 0 ? (size) : 1)) # define Xcalloc(nelem, elsize) calloc(((nelem) > 0 ? (nelem) : 1), (elsize)) #else # define Xmalloc(size) malloc((size)) # define Xrealloc(ptr, size) realloc((ptr), (size)) # define Xcalloc(nelem, elsize) calloc((nelem), (elsize)) #endif -- Jim Wright jwright@quonset.cfht.hawaii.edu Canada-France-Hawaii Telescope Corp.