Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!rutgers!mcnc!sps From: sps@mcnc.org (Stephen Schaefer) Newsgroups: gnu.g++.lib.bug Subject: calloc/cfree Message-ID: Date: 11 Jan 90 16:58:24 GMT Sender: daemon@mcnc.org Distribution: gnu Organization: Microelectronics Center of North Carolina Lines: 35 In libg++ 1.36.2, ChangeLog top reading Wed Jan 3 08:29:43 1990 Doug Lea, malloc.c defines calloc, but does not define cfree. I understand that cfree is superfluous, and may be replaced by free, but we're linking some C++ code with some old C code. The old C code calls calloc and cfree, and when the loader doesn't find cfree in libg++.a, it looks in libc.a. There, cfree is defined in the same module with calloc, and we get a multiply defined error for calloc. The following change to malloc.c prevents the problem: RCS file: RCS/malloc.c,v, file: RCS/malloc.c,v retrieving revision 1.1, file: RCS/malloc.c,v diff -c -r1.1 malloc.c, file: RCS/malloc.c,v *** /tmp/,RCSt1015847 Thu Jan 11 11:56:00 1990 --- malloc.c Wed Jan 10 17:50:51 1990 *************** *** 961,966 **** --- 961,973 ---- }; + /* cfree does nothing except free, but when old code uses it, it would + otherwise drag in a conflicting calloc definition from libc.a */ + inline void cfree(void* mem) + { + free(mem); + } + unsigned int malloc_usable_size(void* mem) { mchunkptr p = (mchunkptr)((char*)mem - SIZE_SZ); -- Stephen P. Schaefer, Postmaster MCNC sps@mcnc.org P.O. Box 12889 ...!mcnc!sps RTP, NC 27709