From 3a37cf450751442c37252156a84edeed44d59e13 Mon Sep 17 00:00:00 2001 From: Jeff Lucovsky Date: Sun, 4 Apr 2021 10:45:09 -0400 Subject: [PATCH] log: Use SCCalloc instead of alloc/clear --- src/util-debug.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/util-debug.c b/src/util-debug.c index 6ad14858a0..bb437f16b6 100644 --- a/src/util-debug.c +++ b/src/util-debug.c @@ -753,10 +753,9 @@ static inline SCLogOPIfaceCtx *SCLogAllocLogOPIfaceCtx(void) { SCLogOPIfaceCtx *iface_ctx = NULL; - if ( (iface_ctx = SCMalloc(sizeof(SCLogOPIfaceCtx))) == NULL) { + if ((iface_ctx = SCCalloc(1, sizeof(SCLogOPIfaceCtx))) == NULL) { FatalError("Fatal error encountered in SCLogallocLogOPIfaceCtx. Exiting..."); } - memset(iface_ctx, 0, sizeof(SCLogOPIfaceCtx)); return iface_ctx; } @@ -1196,12 +1195,9 @@ SCLogInitData *SCLogAllocLogInitData(void) { SCLogInitData *sc_lid = NULL; - /* not using SCMalloc here because if it fails we can't log */ - if ( (sc_lid = SCMalloc(sizeof(SCLogInitData))) == NULL) + if ((sc_lid = SCCalloc(1, sizeof(SCLogInitData))) == NULL) return NULL; - memset(sc_lid, 0, sizeof(SCLogInitData)); - return sc_lid; } @@ -1354,10 +1350,9 @@ void SCLogInitLogModule(SCLogInitData *sc_lid) #endif /* OS_WIN32 */ /* sc_log_config is a global variable */ - if ( (sc_log_config = SCMalloc(sizeof(SCLogConfig))) == NULL) { + if ((sc_log_config = SCCalloc(1, sizeof(SCLogConfig))) == NULL) { FatalError("Fatal error encountered in SCLogInitLogModule. Exiting..."); } - memset(sc_log_config, 0, sizeof(SCLogConfig)); SCLogSetLogLevel(sc_lid, sc_log_config); SCLogSetLogFormat(sc_lid, sc_log_config);