Path: utzoo!utgpu!watmath!clyde!att!cbnews!shurr From: shurr@cbnews.ATT.COM (Larry A. Shurr) Newsgroups: comp.sys.ibm.pc Subject: Re: Turbo C 1.5 malloc bug? Summary: malloc() declaration apparently incorrect Message-ID: <2439@cbnews.ATT.COM> Date: 2 Dec 88 19:40:35 GMT References: <3960@omepd> Reply-To: shurr@cbnews.ATT.COM (Larry A. Shurr) Distribution: na Organization: AT&T Bell Laboratories Lines: 58 In article <3960@omepd> jhunt@omews3.intel.com (Jim Hunt) writes: [Calls to malloc in Turbo C sometimes come out wrong:] [Should be something like this:] > mov ax,# of bytes to allocate > push ax > call far malloc > pop cx > mov [bp+something],ax > mov [bp+something+2],dx >However, sometimes the generated code looks like this: > mov ax, # bytes > push ax > call far malloc > pop cx > cwd > mov [bp+x],ax > mov [bp+x+2],dx I'm using Turbo C 2.0 and I have it right here, so wait a sec... [Time passes] O.K., I'm back now. I tried it and got: push ax call far _malloc pop cx cwd mov word ptr [bp-2],dx mov word ptr [bp-4],ax That's essentially what you're getting. Then I added an include: #includeWith that I got: push ax call far _malloc pop cx mov word ptr [bp-2],dx mov word ptr [bp-4],ax Which is what you want. Alloc.h declares the appropriate function prototype for malloc() and other related functions. Without it, of course, the compiler assumes that malloc() returns an int. So it appears that you simply need to get malloc() defined correctly. Good luck (hope I'm right). regards, Larry -- Signed: Larry A. Shurr (att!cbnews!shurr or osu-cis!apr!las) Clever signature, Wonderful wit, Outdo the others, Be a big hit! - Burma Shave (With apologies to the real thing. Above represents my views only.)