Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!bionet!apple!usc!csun!csuna!abcscnuk From: abcscnuk@csuna.csun.edu (Naoto Kimura) Newsgroups: comp.lang.pascal Subject: Re: Strange... The Turbo Pascal NEW command Message-ID: <2110@csuna.csun.edu> Date: 1 Aug 89 20:50:52 GMT References: <845@dutrun.UUCP> <3534@mentor.cc.purdue.edu> Reply-To: abcscnuk@csuna.csun.edu (Naoto Kimura) Organization: CSU Northridge Lines: 25 In article <3534@mentor.cc.purdue.edu> ags@mentor.cc.purdue.edu (Dave Seaman) writes: >In article <845@dutrun.UUCP> winfave@dutrun.UUCP (A.Verbraeck) writes: >>There's one thing about Turbo Pascal that I don't understand, >>and that is the how the New procedure knows the size of the >>block on the heap to be allocated. > ... (text deleted) ... > >Dave Seaman >ags@seaman.cc.purdue.edu As far as I can guess, it performs a GetMem with the proper size, which is the size of the type that the pointer to points to. That is, if the pointer variable passed to New is a pointer to a record, it allocates enough memory to store that record type. It knows the size because it knows the record type and the size (as given by the SizeOf function). I haven't tried to send a Pointer type (just pointer, not a pointer to anything in particular) into New to see how much it allocates. It's really annoying that I can't allocate a 64K block (I can only allocate 64K - 1 byte). //-n-\\ Naoto Kimura _____---=======---_____ (abcscnuk@csuna.csun.edu) ====____\ /.. ..\ /____==== // ---\__O__/--- \\ Enterprise... Surrender or we'll \_\ /_/ send back your *&^$% tribbles !!