home *** CD-ROM | disk | FTP | other *** search
- /* allocate.c - Interface to malloc/realloc
- *
- * DESCRIPTION
- * These routines, allocate and re_allocate call malloc(3) and
- * realloc(3) respectively. If malloc or realloc returns NULL,
- * an error message is printed and execution is terminated,
- * otherwise, the value returned by malloc/realloc is returned.
- *
- * Copyright (c) 1991,1992 Tim Cook.
- * Non-profit distribution allowed. See README for details.
- */
-
- static char rcsid[] = "$Id: allocate.c,v 1.1 1992/10/30 06:19:34 tim Exp $";
-
- #include "config.h"
-
- extern VOID_PTR malloc () ;
- extern VOID_PTR realloc () ;
-
-
- VOID_PTR allocate (length)
- size_t length ;
- {
- VOID_PTR tmp ;
-
- if ((tmp = malloc (length)) == (VOID_PTR) NULL) {
- perror ("malloc") ;
- exit (1) ; }
- else
- return tmp ;
- }
-
-
- VOID_PTR re_allocate (p, length)
- VOID_PTR p ;
- size_t length ;
- {
- VOID_PTR tmp ;
-
- if ((tmp = realloc (p, length)) == (VOID_PTR) NULL) {
- perror ("realloc") ;
- exit (1) ; }
- else
- return tmp ;
- }
-