Modula-2 Reloaded

A Modern Typesafe & Literate Programming Notation

Site Menu

Project

Specification

Implementation

Recommendations

Reference

Needs Updating

Work in Progress

Wastebasket

Wiki Manual

edit SideBar

Storage

Spec.Storage History

Hide minor edits - Show changes to output

2010-04-18 09:10 by benjk -
Changed line 8 from:
(* TRUE if the implementation uses garbage collection, otherwise FALSE. *)
to:
(* TRUE if this implementation uses garbage collection, otherwise FALSE. *)
2010-04-18 09:08 by benjk -
Changed line 24 from:
END Storage..@]
to:
END Storage.@]
2010-04-18 09:07 by benjk -
Changed lines 3-21 from:
(* Dynamic memory allocation and management *)

FROM SYSTEM IMPORT ADDRESS, WORD;

PROCEDURE (* [NEW] *) ALLOCATE( size : WORD ) : ADDRESS;
  (* Allocates a block of contiguous memory of the specified
size and returns its address.
    If
memory could not be allocated, then NIL is returned. *)

PROCEDURE REALLOCATE( p : ADDRESS; newSize : WORD ) : ADDRESS;
  (* Enlarges a previously allocated memory block at address p to a size newSize.
     If there is not enough contiguous memory to enlarge the block, then a new contiguous
    block of memory
of size newSize is allocated, the previous block copied to the new block.
    The address of the enlarged or newly allocated block is then returned
.
     If memory could not be allocated, then NIL is returned. *)

PROCEDURE (* [DISPOSE] *) DEALLOCATE( p : ADDRESS ) : ADDRESS;
  (* Deallocates a previously allocated block of memory at address p. Always returns NIL. *)

END Storage
.@]
to:
(* Dynamic Memory Allocation and Management *)

FROM SYSTEM IMPORT ADDRESS;

CONST isGarbageCollected = <implementation defined constant>;
(* TRUE if the implementation uses garbage collection, otherwise FALSE. *)

(* Allocator *)

PROCEDURE ALLOCATE( VAR p : ADDRESS;
size : LONGCARD );
(* Allocates a block of contiguous
memory of the specified size and passes
  its address back in p. Passes back NIL if memory could not be allocated.
  This procedure is required by pervasive macro-procedure NEW. *)

(* Deallocator *)

PROCEDURE DEALLOCATE( p : ADDRESS; size : LONGCARD );
(* Deallocates a previously allocated
block of memory of at address p if the
  value
of isGarbageCollection in FALSE, otherwise returns without action.
  This procedure is required by pervasive macro-procedure DISPOSE. *)

END Storage
..@]