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 } Function DosMemAvail : LongInt; { Return the size of the largest contiguous chuck of memory available for use } { --------------------------------------------------------------------------- } Implementation { --------------------------------------------------------------------------- } Function Malloc(Var Ptr; Size : Word) : Word; Begin Inline( $8B/$46/ NIL then begin Inline( $B4/$49/ { mov ah,$49} $C4/$7E/