NetBSD-5.0.2/dist/ntp/libntp/emalloc.c
/* $NetBSD: emalloc.c,v 1.2.38.1 2009/01/16 23:07:42 bouyer Exp $ */
/*
* emalloc - return new memory obtained from the system. Belch if none.
*/
#include "ntp_types.h"
#include "ntp_malloc.h"
#include "ntp_syslog.h"
#include "ntp_stdlib.h"
#if defined SYS_WINNT && defined DEBUG
#include <crtdbg.h>
#endif
#if defined SYS_WINNT && defined DEBUG
void *
debug_emalloc(
size_t size,
char *filename,
int line
)
{
char *mem;
if ((mem = (char *)_malloc_dbg(size, _NORMAL_BLOCK, filename, line)) == 0) {
msyslog(LOG_ERR, "Exiting: No more memory!");
exit(1);
}
return mem;
}
#else
void *
emalloc(
size_t size
)
{
char *mem;
if ((mem = (char *)malloc(size)) == 0) {
msyslog(LOG_ERR, "Exiting: No more memory!");
exit(1);
}
return mem;
}
#endif