Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!decvax!ucbvax!GE-CRD.ARPA!montnaro%chenengo.tcpip
From: montnaro%chenengo.tcpip@GE-CRD.ARPA.UUCP
Newsgroups: mod.computers.vax
Subject: malloc, alloc, etc., and brk and sbrk
Message-ID: <8612192244.AA01572@ucbvax.Berkeley.EDU>
Date: Thu, 18-Dec-86 23:12:00 EST
Article-I.D.: ucbvax.8612192244.AA01572
Posted: Thu Dec 18 23:12:00 1986
Date-Received: Fri, 19-Dec-86 23:59:55 EST
Sender: daemon@ucbvax.BERKELEY.EDU
Organization: The ARPA Internet
Lines: 51
Approved: info-vax@sri-kl.arpa

Received: by chenengo.steinmetz (3.2/1.1x Steinmetz)
	id AA09105; Thu, 18 Dec 86 23:06:55 EST
Date: Thu, 18 Dec 86 23:06:55 EST
From: Skip Montanaro 
Posted-Date: Thu, 18 Dec 86 23:06:55 EST
Message-Id: <8612190406.AA09105@chenengo.steinmetz>
To: sasaki@harvard.harvard.edu
Cc: vms-gnu-emacs@harvard.harvard.edu, info-vax@sri-kl.arpa
In-Reply-To: sasaki%harvard.HARVARD.EDU.tcpip@csbvax.steinmetz's message of 18 Dec 86 21:54 EST
Subject: malloc, alloc, etc., and brk and sbrk


Marty Sasaki writes:

    According to the documentation for VAX-11 C you can't use malloc, calloc,
    etc., with brk and sbrk. Gnu Emacs uses brk and sbrk, but does it's own
    version of malloc, realloc, etc. This is fine, but it appears that
    getenv (amoung others) calls calloc. This then violates the rule about
    mixing allocation routines.

I tried the following trivial test program (no comments on it please. it
served my purposes.)

------------------------------------------------------------------------------
extern int getenv();

malloc(n) unsigned n; { static int space[1024]; return space; }

main ()
{
  printf("%s\n", getenv("TERM"));
}
------------------------------------------------------------------------------

I compiled and linked it with /DEBUG. When I linked it with the shareable
RTL the linker said my version of malloc() was multiply defined. When I
linked it with the normal RTL the version in the RTL turned up multiply
defined. When I ran the latter version and set a break at malloc() it
stopped when entering my version (not so with the shareable version).

I suspect that the malloc()/brk() restriction is a non-problem with the
current version of VMS GNU Emacs, since it does not appear to be linked with
the shareable RTL.  I think the GNU version of malloc() is being referenced.
However, I routinely linked the old version (17.VMS-4) with the shareable
RTL with no apparent problems. In fact, that's what we use on our VMS VAXen.

Skip Montanaro

ARPA: montanaro%desdemona.tcpip@ge-crd.arpa
UUCP: seismo!rochester!steinmetz!desdemona!montanaro
GE DECnet: csbvax::mrgate!montanaro@desdemona@smtp@tcpgateway