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 15 void * 16 debug_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 33 void * 34 emalloc( 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 49