Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!uw-beaver!sumax!polari!rwing!seaeast!comcon!tim From: tim@comcon.UUCP (Tim Brown) Newsgroups: comp.unix.sysv386 Subject: malloc Keywords: fails Message-ID: <537@comcon.UUCP> Date: 9 Dec 90 22:00:31 GMT Organization: Computer Connection, Anchorage Alaska Lines: 44 Does anyone know why this code should core dump? ----------------------- 1. first in main(): names = NULL; ---------------------- 2. Then: if(some_condition && names != NULL) { free(names); names = NULL; } ---------------------- 3. Then: if(names == NULL) if((names = (char *)malloc(BUFF_SIZE)) == NULL) { perror("malloc"); exit(errno); } ------------------------- I set this up by setting the char *names equal to NULL at run time and then when I want to change the memory allocation, I free(names) and once again set names = NULL, that way I can call the malloc code repeatedly allocating a different size chunk each time. I want to be able to run chunks 2&3 repeatedly. On my system, ISC2.2, it core dumps on the third time thru. On an IBM6000, it works as expected. I suspect a bug in ISC's malloc. How are others doing this? It core dumps at the malloc according to sdb. I know this is comp.lang.c stuff but it seems to possibly be isolated to ISC. Thanks for any help. -- Tim Brown | Computer Connection | uunet!seaeast.wa.com!comcon!tim |