{$S-,R-,V-,I-,N-,B-,F-} {$IFNDEF Ver40} {Allow overlays} {$F+,O-,X+,A-} {$ENDIF} UNIT MemAlloc; { Purpose is to provide the ability to create (destroy) dynamic variables } { without needing to reserve heap space at compile time. } INTERFACE FUNCTION Malloc(VAR Ptr; Size : Word) : Word; { Allocate free memory and return a pointer to it. The amount of memory } { requested from DOS is calculated as (Size/4)+1 paragraphs. If the } { allocation is successful, the untyped VAR parameter Ptr will be populated } { with the address of the allocated memory block, and the function will return} { a zero result. Should the request to DOS fail, Ptr will be populated with } { the value NIL, and the function will return the appropriate DOS error code. } FUNCTION Dalloc(VAR Ptr) : Word; { Deallocate the memory pointed to by the untyped VAR parameter Ptr } IMPLEMENTATION FUNCTION Malloc(VAR Ptr; Size : Word) : Word; BEGIN INLINE( $8B / $46 / NIL THEN BEGIN INLINE( $B4 / $49 / { mov ah,$49} $C4 / $7E /