Move memory allocation code to a new function in MM.
This commit is contained in:
parent
7c0492cfa4
commit
20770f388e
28
MM.pas
28
MM.pas
|
@ -23,6 +23,7 @@
|
||||||
{ GCalloc - allocate & clear memory from the global pool }
|
{ GCalloc - allocate & clear memory from the global pool }
|
||||||
{ GInit - initialize a global pool }
|
{ GInit - initialize a global pool }
|
||||||
{ GMalloc - allocate memory from the global pool }
|
{ GMalloc - allocate memory from the global pool }
|
||||||
|
{ GLongMalloc - allocate global memory }
|
||||||
{ LInit - initialize a local pool }
|
{ LInit - initialize a local pool }
|
||||||
{ LMalloc - allocate memory from the local pool }
|
{ LMalloc - allocate memory from the local pool }
|
||||||
{ Malloc - allocate memory }
|
{ Malloc - allocate memory }
|
||||||
|
@ -73,6 +74,15 @@ procedure GInit;
|
||||||
{ Initialize a global pool }
|
{ Initialize a global pool }
|
||||||
|
|
||||||
|
|
||||||
|
function GLongMalloc (bytes: longint): ptr;
|
||||||
|
|
||||||
|
{ Allocate a potentially large amount of global memory. }
|
||||||
|
{ }
|
||||||
|
{ Parameters: }
|
||||||
|
{ bytes - number of bytes to allocate }
|
||||||
|
{ ptr - points to the first byte of the allocated memory }
|
||||||
|
|
||||||
|
|
||||||
function GMalloc (bytes: integer): ptr;
|
function GMalloc (bytes: integer): ptr;
|
||||||
|
|
||||||
{ Allocate memory from the global pool. }
|
{ Allocate memory from the global pool. }
|
||||||
|
@ -182,6 +192,24 @@ globalPtr := pointer(ord4(globalPtr) + bytes);
|
||||||
end; {GMalloc}
|
end; {GMalloc}
|
||||||
|
|
||||||
|
|
||||||
|
function GLongMalloc {bytes: longint): ptr};
|
||||||
|
|
||||||
|
{ Allocate a potentially large amount of global memory. }
|
||||||
|
{ }
|
||||||
|
{ Parameters: }
|
||||||
|
{ bytes - number of bytes to allocate }
|
||||||
|
{ ptr - points to the first byte of the allocated memory }
|
||||||
|
|
||||||
|
var
|
||||||
|
myhandle: handle; {for dereferencing the block}
|
||||||
|
|
||||||
|
begin {GLongMalloc}
|
||||||
|
myhandle := NewHandle(bytes, globalID, $C000, nil);
|
||||||
|
if ToolError <> 0 then TermError(5);
|
||||||
|
GLongMalloc := myhandle^;
|
||||||
|
end; {GLongMalloc}
|
||||||
|
|
||||||
|
|
||||||
procedure LInit;
|
procedure LInit;
|
||||||
|
|
||||||
{ Initialize a local pool }
|
{ Initialize a local pool }
|
||||||
|
|
15
Symbol.pas
15
Symbol.pas
|
@ -306,16 +306,6 @@ type
|
||||||
var
|
var
|
||||||
staticNum: packed array[1..6] of char; {static variable number}
|
staticNum: packed array[1..6] of char; {static variable number}
|
||||||
|
|
||||||
{---------------------------------------------------------------}
|
|
||||||
|
|
||||||
{GS memory manager}
|
|
||||||
{-----------------}
|
|
||||||
|
|
||||||
procedure DisposeHandle (theHandle: handle); tool ($02, $10);
|
|
||||||
|
|
||||||
function NewHandle (blockSize: longint; userID, memAttributes: integer;
|
|
||||||
memLocation: ptr): handle; tool($02, $09);
|
|
||||||
|
|
||||||
{- Imported from expression.pas --------------------------------}
|
{- Imported from expression.pas --------------------------------}
|
||||||
|
|
||||||
procedure GenerateCode (tree: tokenPtr); extern;
|
procedure GenerateCode (tree: tokenPtr); extern;
|
||||||
|
@ -726,7 +716,6 @@ procedure DoGlobals;
|
||||||
|
|
||||||
var
|
var
|
||||||
buffPtr: ptr; {pointer to data buffer}
|
buffPtr: ptr; {pointer to data buffer}
|
||||||
buffHandle: handle; {handle to data buffer}
|
|
||||||
count: integer; {# of duplicate records}
|
count: integer; {# of duplicate records}
|
||||||
disp: longint; {disp into buffer (for output)}
|
disp: longint; {disp into buffer (for output)}
|
||||||
endDisp: longint; {ending disp for current chunk}
|
endDisp: longint; {ending disp for current chunk}
|
||||||
|
@ -801,9 +790,7 @@ procedure DoGlobals;
|
||||||
begin {StaticInit}
|
begin {StaticInit}
|
||||||
{allocate buffer}
|
{allocate buffer}
|
||||||
{(+3 for possible bitfield overhang)}
|
{(+3 for possible bitfield overhang)}
|
||||||
buffHandle := NewHandle(variable^.itype^.size+3, globalID, $8000, nil);
|
buffPtr := GLongMalloc(variable^.itype^.size+3);
|
||||||
if ToolError <> 0 then TermError(5);
|
|
||||||
buffPtr := buffHandle^;
|
|
||||||
|
|
||||||
relocs := nil; {evaluate initializers}
|
relocs := nil; {evaluate initializers}
|
||||||
ip := variable^.iPtr;
|
ip := variable^.iPtr;
|
||||||
|
|
Loading…
Reference in New Issue