Newton%CIT-Vax@sri-unix.UUCP (06/13/84)
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 <whoami.h>
#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 <whoami.h>
/* lint,? whats that? */
#ifdef ZAPHOD
unsigned pmalloc(nbytes)
register unsigned nbytes;
{
register unsigned addr;
return ( ( (addr = sbrk(nbytes)) == -1) ? 0 : addr);
}
#endif