Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-08 - 43,50512/alloc.b36
There are no other files named alloc.b36 in the archive.
MODULE ALLOC=
!Module to do core allocation
!Currently uses CORMGT package written by John Xenakis
BEGIN
!
! Table of Contents
!
FORWARD ROUTINE
ALLOC,
FREE;

!
! Conditional Compilation
!
COMPILETIME FTDEBUG=1;

!
! REQUIRE & LIBRARY declarations
!
REQUIRE 'INTR.REQ';

!
! Version info
!

THIS_IS [ALLO] VERSION [1] EDIT [3] DATE [20,NOV,78]

!
! External references
!
EXTERNAL ROUTINE CORGET,CORFRE,CORRES;	!Entry points in CORMGT
EXTERNAL ROUTINE ZERO;

!
! Global routines
!
GLOBAL ROUTINE ALLOC(SIZE)=
!Routine to get some core.  Size is the # of words
BEGIN
!CORGET wants its argument in the LH of 1
LOCAL V;

IF .SIZE LEQ 0
THEN	BEGIN	!Tried to allocate nothing or less than nothing!!
	DEBUGMSG(TYPE('%NETAZB Attempt to allocate zero-length block',CRLF));
	%IF FTDEBUG
		%THEN
		BEGIN
		OWN ALLZERO;	!Count of # of times this happened
		ALLZERO=.ALLZERO+1;
		END
		%FI;
	RETURN 0;
	END;

NOINTS((	V=CORGET(.SIZE)	));!CORGET is not reentrant!

ZERO(.V,.V+.SIZE-1);		!Clear it first
IF .V NEQ 0
THEN RETURN .V
ELSE ERROR(ALLOCF)	!Allocation failed
END;	!ALLOC

GLOBAL ROUTINE FREE(ADDR,SIZE)=
!Routine to free some core. ADDR is the address, SIZE is the # of words
BEGIN
IF .SIZE LEQ 0
THEN	BEGIN	!Tried to free nothing or less than nothing!!
	DEBUGMSG(TYPE('%NETFZB Attempt to free zero-length block',CRLF));
	%IF FTDEBUG
		%THEN
		BEGIN
		OWN FREZERO;	!Count of # of times this happened
		FREZERO=.FREZERO+1;
		END
		%FI;
	RETURN
	END;

NOINTS((	CORFRE(.ADDR,.SIZE)	));!CORFRE is not reentrant either
RETURN WIN;
END;

END ELUDOM