/*  This file should be edited with 4-column tabs! */
/*  Author: Mark Moraes <moraes@csri.toronto.edu> */

/*LINTLIBRARY*/

#include "defs.h"
#include "globals.h"

RCSID("$Header: /j/moraes/shmem/malloc/malloc/RCS/emalloc.c,v 1.7 89/10/31 02:27:34 moraes Exp $");

/*
 *  malloc which dies if it can't allocate enough storage.
 */
univptr_t
xemalloc(nbytes)
size_t nbytes;
{
	univptr_t cp = malloc(nbytes);

	if (cp == 0) {
		(void) fputs("No more memory for emalloc\n", stderr);
#ifdef DEBUG
		(void) fflush(stderr);
		(void) fflush(_malloc_statsfile);
		abort();
#else
		exit(EXIT_FAILURE);
#endif
	}

	return(cp);
}

/*
 *  realloc which dies if it can't allocate enough storage.
 */
univptr_t
xerealloc(ptr, nbytes)
univptr_t ptr;
size_t nbytes;
{
	univptr_t cp = realloc(ptr, nbytes);

	if (cp == 0) {
		(void) fputs("No more memory for erealloc\n", stderr);
#ifdef DEBUG
		(void) fflush(stderr);
		(void) fflush(_malloc_statsfile);
		abort();
#else
		exit(EXIT_FAILURE);
#endif
	}

	return(cp);
}
