home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume10
/
parseargs
/
ckalloc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-02-16
|
1KB
|
51 lines
#include <useful.h>
#include <funclist.h>
VERSIONID("$Header: ckalloc.c,v 2.0 89/12/24 00:56:21 eric Exp $");
/*
** CKALLOC -- allocate memory, checking for error conditions
**
** If we cannot allocate memory, we call the list of functions
** in OutOfMemoryFuncs. We then try again. If the second attempt
** fails, we terminate the process.
**
** Parameters:
** size -- the number of bytes of memory to be allocated.
**
** Returns:
** A pointer to the allocated memory.
** Never returns if memory cannot be allocated.
**
** Side Effects:
** As implied by memory allocation.
**
** Globals:
** OutOfMemoryFuncs -- a FUNCLIST that is called when memory
** cannot be allocated.
**
** Author:
** Eric Allman
** University of California, Berkeley
*/
FUNCLIST *OutOfMemoryFuncs = FUNCLISTNULL;
ARBPTR
ckalloc(size)
unsigned int size;
{
ARBPTR p;
extern char *malloc ARGS((unsigned int));
p = __ malloc(size);
if (p == ARBNULL)
{
funclist_call(OutOfMemoryFuncs, ARBNULL);
p = __ malloc(size);
if (p == ARBNULL)
syserr("ckalloc: out of memory");
}
return (p);
}