mad-2@kub.nl (C. Wekx) (07/20/90)
Yo folks, does anyone happen to know why Turbo C 2.0's malloc function is malfunctioning? They do not always signal an out of memory situation, but overwrite the first part of their segment instead. Joris
grimlok@hubcap.clemson.edu (Mike Percy) (07/20/90)
mad-2@kub.nl (C. Wekx) writes: >Yo folks, > does anyone happen to know why Turbo C 2.0's malloc >function is malfunctioning? They do not always signal an out of memory >situation, but overwrite the first part of their segment instead. Yo, Sounds like you've written memory via a NULL pointer. If you do a malloc() and malloc returns NULL, there was no memory. Sound like you did a malloc(), got a return of NULL, didn't bother to check it, and wrote through the NULL Pointer -- DS:0000 -- blasting across the low end of the segment. "How much char could a char star star if char star could star char?" Mike Percy grimlok@hubcap.clemson.edu ISD, Clemson University mspercy@clemson.BITNET (803)656-3780 mspercy@clemson.clemson.edu
spengler@lance.tis.llnl.gov (Tom Spengler) (07/21/90)
In article <1217@kubix.kub.nl> mad-2@kub.nl (C. Wekx) writes: > >Yo folks, > > > does anyone happen to know why Turbo C 2.0's malloc >function is malfunctioning? They do not always signal an out of memory >situation, but overwrite the first part of their segment instead. > > > > > Joris On a couple of occasions, I was *sure* that some function in the malloc() family was misbehaving, but not so. It was me, and the cause in each case was a bogus free(). A free() on a wrong pointer will corrupt the free list. The results of this corruption may not be immediately seen, but at some point, the program will fail in puzzling, and usually catastrophic, ways on DOS. So, check all pointers returned by malloc() and friends, and check all your free()s. Hope this helps. --Tom Spengler (spengler@tis.llnl.gov)
mad-2@kub.nl (C. Wekx) (07/23/90)
The problem I described can not be due to a returning NULL pointer. I always check for this kind of mishaps in my programs and even the TC-debugger shows a non-NULL pointer.... Joris