Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!decwrl!fernwood!edsel!devin From: devin@lucid.com (Matthieu Devin) Newsgroups: comp.windows.x Subject: Re: X.V11R3 local network problem Summary: Malloc(0) returns NULL on suns 3 Message-ID: <1984@edsel> Date: 15 Apr 89 00:17:50 GMT References: <24794.8904111227@eik.II.UIB.NO> Organization: Lucid, Inc. Menlo Park, CA Lines: 66 In article <24794.8904111227@eik.II.UIB.NO>, svenole@EIK.II.UIB.NO (Sven-Ole Skrivervik) writes: > I have some problems with release 3 that I did not have with release 2. > I can`t display applications through the network with this installation. I > just get segmentation fault when I try to start an application on one I had the same problems with release 3.2 of Sun OS. It comes from the fact that some times (but not always..) malloc(0) returns a NULL pointer. Both Xlib, in _XConnectDisplay when allocating visuals, and Xt when overriding translation tables, suppose that malloc(0) returning NULL means there is no more memory available. Q: How much memory do you need to allocate no space :-) You can overrid that by defing the flag MALLOC_0_RETURNS_NULL in Sun.macros, (and make Makefiles, etc..). There is no such flag for Xt so you much edit Alloc.c to test if arguments are 0 and change them to 1.. Here is a context diff *** Alloc.c Wed Apr 12 08:49:42 1989 --- RCS/Alloc.c Fri Apr 10 17:14:56 1989 *************** *** 41,49 **** unsigned size; { char *ptr; - #ifdef sun - if(size == 0) size = 1; - #endif if ((ptr = malloc(size)) == NULL) XtErrorMsg("allocError","malloc","XtToolkitError", "Cannot perform malloc", (String *)NULL, (Cardinal *)NULL); --- 41,46 ---- *************** *** 54,62 **** char *ptr; unsigned size; { - #ifdef sun - if(size == 0) size = 1; - #endif if (ptr == NULL) return(XtMalloc(size)); else if ((ptr = realloc(ptr, size)) == NULL) XtErrorMsg("allocError","realloc","XtToolkitError", --- 51,56 ---- *************** *** 68,77 **** unsigned num, size; { char *ptr; - #ifdef sun - if(size == 0) size = 1; - if(num == 0) num = 1; - #endif if ((ptr = calloc(num, size)) == NULL) XtErrorMsg("allocError","calloc","XtToolkitError", "Cannot perform calloc", (String *)NULL, (Cardinal *)NULL); --- 62,67 ---- -- Matthieu Devin Lucid Inc, 707 Laurel Street, Menlo Park, CA 94025 devin@lucid.com (415)329-8400 x 5574