Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site dicomed.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!dicomed!papke From: papke@dicomed.UUCP (Kurt Papke) Newsgroups: net.micro.pc Subject: Re: Problems with Microsoft C V 3.0 memory routines Message-ID: <649@dicomed.UUCP> Date: Thu, 14-Nov-85 08:23:19 EST Article-I.D.: dicomed.649 Posted: Thu Nov 14 08:23:19 1985 Date-Received: Sat, 16-Nov-85 09:38:30 EST References: <279@infinet.UUCP> Reply-To: papke@dicomed.UUCP (Kurt Papke) Organization: DICOMED Corp., Minneapolis Lines: 32 In article <279@infinet.UUCP> cgf@infinet.UUCP (Chris Faylor) writes: >{} >Has anyone out there noticed any problems with the realloc routine >distributed with Microsoft C? It seems to sometimes leave garbage >in the middle of a reallocated block of memory if the newly malloc'ed >block overlaps the old. I have used the realloc() routine quite a bit and have never experienced the problem you describe. >Looking at the code, it seems pretty obvious that there will be times >when this will definitely happen. It will always fail if you try >to increase the size of a block from, say, 10 bytes to 16 bytes, and >there are 6 free bytes immediately preceding the original ten. >What happens is that realloc first frees the block it is trying to >expand, then malloc sets aside the only available 16 bytes, placing >a memory size header in the middle of the original 10 byte block. >Then realloc copies the old block, header and all, up 6 bytes. Could be. How do you know this without the sources to the run-time library ?? >In general, it seems that malloc does not behave well if you have >the misfortune of running out of memory. I have not completely >corroborated it, but it looks like a pointer somewhere gets >screwed up. After returning a NULL (indicating that there isn't >enough contiguous memory for the request) it appears that it will >sometimes start allocating new memory over previously allocated blocks. >Anybody else seen this? No, although most of the code I've written with 3.0 has no choice but to roll over and die when it runs out of heap !!