2003-12-04 19:23:34 +03:00
|
|
|
/* $NetBSD: emalloc.c,v 1.2 2003/12/04 16:23:36 drochner Exp $ */
|
2000-03-29 16:38:44 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* emalloc - return new memory obtained from the system. Belch if none.
|
|
|
|
*/
|
|
|
|
#include "ntp_types.h"
|
|
|
|
#include "ntp_malloc.h"
|
|
|
|
#include "ntp_syslog.h"
|
2003-12-04 19:05:14 +03:00
|
|
|
#include "ntp_stdlib.h"
|
2000-03-29 16:38:44 +04:00
|
|
|
|
|
|
|
#if defined SYS_WINNT && defined DEBUG
|
|
|
|
#include <crtdbg.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined SYS_WINNT && defined DEBUG
|
|
|
|
|
|
|
|
void *
|
|
|
|
debug_emalloc(
|
|
|
|
u_int size,
|
|
|
|
char *filename,
|
|
|
|
int line
|
|
|
|
)
|
|
|
|
{
|
|
|
|
char *mem;
|
|
|
|
|
|
|
|
if ((mem = (char *)_malloc_dbg(size, _NORMAL_BLOCK, filename, line)) == 0) {
|
2003-12-04 19:05:14 +03:00
|
|
|
msyslog(LOG_ERR, "Exiting: No more memory!");
|
2000-03-29 16:38:44 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
return mem;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
void *
|
|
|
|
emalloc(
|
|
|
|
u_int size
|
|
|
|
)
|
|
|
|
{
|
|
|
|
char *mem;
|
|
|
|
|
|
|
|
if ((mem = (char *)malloc(size)) == 0) {
|
2003-12-04 19:05:14 +03:00
|
|
|
msyslog(LOG_ERR, "Exiting: No more memory!");
|
2000-03-29 16:38:44 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
return mem;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|