Better handle low memory conditions.

remotes/origin/master-1.1.x
Victor Julien 16 years ago
parent 57f5327d56
commit 22f770f3bf

@ -943,10 +943,10 @@ SCLogInitData *SCLogAllocLogInitData(void)
{ {
SCLogInitData *sc_lid = NULL; SCLogInitData *sc_lid = NULL;
if ( (sc_lid = malloc(sizeof(SCLogInitData))) == NULL) { /* not using SCMalloc here because if it fails we can't log */
SCLogError(SC_ERR_FATAL, "Fatal error encountered initializing the logging subsytem. Out of memory. Exiting..."); if ( (sc_lid = malloc(sizeof(SCLogInitData))) == NULL)
exit(EXIT_FAILURE); return NULL;
}
memset(sc_lid, 0, sizeof(SCLogInitData)); memset(sc_lid, 0, sizeof(SCLogInitData));
return sc_lid; return sc_lid;

@ -154,6 +154,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
#define SCFree(a) free((a)) #define SCFree(a) free((a))
#endif #endif
#if 0
#define SCMalloc(a) ({ \ #define SCMalloc(a) ({ \
void *ptrmem = NULL; \ void *ptrmem = NULL; \
\ \
@ -214,6 +215,11 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
} \ } \
(void*)ptrmem; \ (void*)ptrmem; \
}) })
#endif
#define SCMalloc malloc
#define SCRealloc realloc
#define SCCalloc calloc
#define SCStrdup strdup
#define SCFree(a) ({ \ #define SCFree(a) ({ \
free(a); \ free(a); \

Loading…
Cancel
Save