PageRenderTime 29ms CodeModel.GetById 22ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/ntp/libntp/emalloc.c

https://bitbucket.org/freebsd/freebsd-head/
C | 48 lines | 36 code | 9 blank | 3 comment | 6 complexity | 5f04a29149ea13d89169215bd6917b23 MD5 | raw file
 1/*
 2 * emalloc - return new memory obtained from the system.  Belch if none.
 3 */
 4#include "ntp_types.h"
 5#include "ntp_malloc.h"
 6#include "ntp_syslog.h"
 7#include "ntp_stdlib.h"
 8
 9#if defined SYS_WINNT && defined DEBUG
10#include <crtdbg.h>
11#endif
12
13#if defined SYS_WINNT && defined DEBUG
14
15void *
16debug_emalloc(
17	u_int size,
18	char *filename,
19	int line
20	)
21{
22	char *mem;
23
24	if ((mem = (char *)_malloc_dbg(size, _NORMAL_BLOCK, filename, line)) == 0) {
25		msyslog(LOG_ERR, "Exiting: No more memory!");
26		exit(1);
27	}
28	return mem;
29}
30
31#else
32
33void *
34emalloc(
35	u_int size
36	)
37{
38	char *mem;
39
40	if ((mem = (char *)malloc(size)) == 0) {
41		msyslog(LOG_ERR, "Exiting: No more memory!");
42		exit(1);
43	}
44	return mem;
45}
46
47
48#endif