aboutsummaryrefslogtreecommitdiff
path: root/libntp/emalloc.c
blob: 2fe4c386217e77f5b565f5801d7ec119fbcd4193 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * 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(
	u_int 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(
	u_int size
	)
{
	char *mem;

	if ((mem = (char *)malloc(size)) == 0) {
		msyslog(LOG_ERR, "Exiting: No more memory!");
		exit(1);
	}
	return mem;
}


#endif