Article View: comp.os.msdos.programmer
Article #1932Re: alloca() for TurboC
From: Stephen C. Trier
Date: Wed, 22 Aug 1990 03:22
Date: Wed, 22 Aug 1990 03:22
21 lines
1634 bytes
1634 bytes
Here's a version of alloca I use. It's my clone of a version from some
piece of PD software I saw a year or two ago.
#define alloca(A) ((_SP -= ((A)+1) & 0xFFFE), (void far *)(((unsigned long)_SS << 16) | _SP))
The idea is to subtract the size A from the stack pointer, making sure
it's word-aligned. (This is the (_SP -= ((A)+1) & 0xFFFE) part.) Then,
since alloca returns a pointer to the allocated space, the macro must
kludge together a far pointer from the stack segment and stack pointer.
I should add the disclaimer that I'm not entirely sure that this works.
It's my own version of someone else's, but I changed it a bit. (I don't
remember what the original looked like.)
Hope this helps!
--
Stephen Trier Case Western Reserve University
Home: sct@seldon.clv.oh.us Information Network Services
Work: trier@cwlim.ins.cwru.edu
I may work for the University, but that doesn't mean I speak for them.
Technical Details
Message-ID:
<1990Aug22.032243.18214@usenet.ins.cwru.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!usenet.ins.cwru.edu!cwlim!trierReferences:
<2745@onion.reading.ac.uk> <3860@bingvaxu.cc.binghamton.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!usenet.ins.cwru.edu!cwlim!trier From: trier@cwlim.CWRU.EDU (Stephen C. Trier) Newsgroups: comp.os.msdos.programmer,alt.msdos.programmer,comp.lang.c Subject: Re: alloca() for TurboC Keywords: alloca, DOS, TurboC, assembly Message-ID: <1990Aug22.032243.18214@usenet.ins.cwru.edu> Date: 22 Aug 90 03:22:43 GMT References: <2745@onion.reading.ac.uk> <3860@bingvaxu.cc.binghamton.edu> Sender: news@usenet.ins.cwru.edu Reply-To: trier@po.CWRU.Edu Organization: Case Western Reserve Univ. Cleveland, Ohio, (USA) Lines: 22