Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ alloc(III) — UNIX 6th Edition

Media Vault

Software Library

Restoration Projects

Artifacts Sought

ALLOC(III)  −  PWB/UNIX 3/1/74

NAME

alloc, free − core allocator

SYNOPSIS

char *alloc(size)
free(ptr)
char *ptr;

DESCRIPTION

Alloc and free provide a simple general-purpose core management package.  Alloc is given a size in bytes; it returns a pointer to an area at least that size which is even and hence can hold an object of any type.  The argument to free is a pointer to an area previously allocated by alloc; this space is made available for further allocation.  Needless to say, grave disorder will result if the space assigned by alloc is overrun or if some random number is handed to free.  The routine uses a first-fit algorithm which coalesces blocks being freed with other blocks already free. It calls sbrk (see "break (II))" to get more core from the system when there is no suitable space already free. 

DIAGNOSTICS

Returns −1 if there is no available core. 

BUGS

Allocated memory contains garbage instead of being cleared. 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026