Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!spool.mu.edu!uunet!mcsun!unido!ira.uka.de!smurf!artcom0!hb.maus.de!ms.maus.de!Kai_Henningsen From: Kai_Henningsen@ms.maus.de (Kai Henningsen) Newsgroups: comp.lang.pascal Subject: Re: need dynamic array on heap Message-ID: <13834@ms.maus.de> Date: 22 Apr 91 20:32:00 GMT Article-I.D.: ms.13834 Distribution: world,comp Organization: Maus Mailbox Netz - UUCP-Gateway Bremen Lines: 24 BB>>> type byte_buf = array[1..64000] of byte; BB>>> byte_buf_ptr = ^byte_buf; BB>>> BB>>> var buffer : pointer; BB>>> . BB>>> . BB>>> getmem(buffer,somesize); { Allocate only as many bytes as you need } BB>>> byte_buf_ptr(buffer)^[2] := somevalue; BB> You most certainly do need the typecast. Notice the getmem call BB> does not use the typecast; it's the reference to the pointer BB> as a pointer to an array of bytes that requires the typecast. BB> Guess you weren't reading too close :). BB> BB> As I said, I use this method frequently. You don't get a free BB> lunch; bypassing Pascal's strong type checking takes a little BB> more work. You most certainly don't need the type cast, you need a correct type definition. As I already said, declare buffer as pointer to an array, not as simply "pointer"; then, you can leave any casts out. I do it all the time. MfG Kai