Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!vaxine!wjh12!genrad!decvax!ittvax!dcdwest!sdcsvax!sdcrdcf!hplabs!sri-unix!Newton@CIT-Vax From: Newton%CIT-Vax@sri-unix.UUCP Newsgroups: net.lang.prolog Subject: CProlog and malloc 'bug' fix Message-ID: <1011@sri-arpa.UUCP> Date: Wed, 13-Jun-84 16:45:48 EDT Article-I.D.: sri-arpa.1011 Posted: Wed Jun 13 16:45:48 1984 Date-Received: Thu, 21-Jun-84 04:38:48 EDT Lines: 55 From: Newton@CIT-Vax (Mike Newton) Hi -- Those installations that run CProlog and that use the "Caltech malloc" may not be able to use all of available core. Example: We run with 16 Mbyte process space, and if a user types cprolog -h 4096 -g 4096 CProlog complains for lack of space. The reason behind this is that malloc adds 4 bytes of it's own and then rounds up to the next power of two. WARNING: I believe the "Caltech malloc" was the standard one distributed with 4.2. One fix -- modify sysbits.c as: [Line 397]: for (i = 0; i < NAreas; i++) s += Size[i]; #include#ifdef ZAPHOD if ((r = pmalloc(s)) == NULL) { /* we want it ALL! */ #else if ((r = malloc(s)) == NULL) { /* OLD code -- wastes space */ #endif perror("Prolog"); exit(BAD_EXIT); } and also modify the makefile to include pmalloc instead of malloc. Pmalloc is: /* * pmalloc.c (WHOMPED ON: 5/9/84) * This is a replacement for the standard * malloc for use in CProlog. -- MONewton */ #include /* lint,? whats that? */ #ifdef ZAPHOD unsigned pmalloc(nbytes) register unsigned nbytes; { register unsigned addr; return ( ( (addr = sbrk(nbytes)) == -1) ? 0 : addr); } #endif