Mega Code Archive

 
Categories / Delphi / Examples
 

Incptr

Subject: Re: DELPHI: addressing getmem'ed memory The following should do the job (both for pointers retrieved with GlobalAlloc/GlobalLock and GetMem): PROCEDURE IncPtr(VAR p : Pointer) : Pointer; BEGIN IF (Ofs(p^)=$FFFF) THEN p:=Ptr(Seg(p^)+SelectorInc,0) ELSE p:=Ptr(Seg(p^),Ofs(p^)+1); END; This handles the case when you cross a segment boundary as well. (SelectorInc is a predefined Delphi variable.) Marten