Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!cwjcc!hal!ncoast!allbery
From: allbery@ncoast.UUCP (Brandon S. Allbery)
Newsgroups: comp.sys.ibm.pc
Subject: Re: Turbo C 1.5 malloc bug?
Message-ID: <13216@ncoast.UUCP>
Date: 6 Dec 88 23:41:00 GMT
References: <3960@omepd>
Reply-To: allbery@ncoast.UUCP (Brandon S. Allbery)
Followup-To: comp.sys.ibm.pc
Distribution: na
Organization: Cleveland Public Access UN*X, Cleveland, Oh
Lines: 33

As quoted from <3960@omepd> by jhunt@omews3.intel.com (Jim Hunt):
+---------------
| I have been programming with Turbo C 1.5 recently and have found what appears
| to be a bug in the code generated for a malloc call.  USUALLY the code that
| is generated looks something like this:
| 
|    push ax
|    call far malloc
|    pop cx
|    mov [bp+something],ax
|    mov [bp+something+2],dx
| 
| However, sometimes the generated code looks like this:
| 
|    push ax
|    call far malloc
|    pop cx
|    cwd
|    mov [bp+x],ax
|    mov [bp+x+2],dx
+---------------

As a guess, I'd say that the latter occurs when you forget to declare
malloc() as returning "char *" or "char far *".  Remember that sizeof (int)
!= sizeof (char *)....

++Brandon
-- 
Brandon S. Allbery, comp.sources.misc moderator and one admin of ncoast PA UN*X
uunet!hal.cwru.edu!ncoast!allbery  	    ncoast!allbery@hal.cwru.edu
allberyb@skybridge.sdi.cwru.edu	      		   allbery@uunet.uu.net
comp.sources.misc is moving off ncoast -- please do NOT send submissions direct
      Send comp.sources.misc submissions to comp-sources-misc@.