From: Jeff Lucovsky Date: Sun, 4 Apr 2021 14:45:09 +0000 (-0400) Subject: log: Use SCCalloc instead of alloc/clear X-Git-Tag: suricata-7.0.0-rc1~219 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a37cf450751442c37252156a84edeed44d59e13;p=thirdparty%2Fsuricata.git log: Use SCCalloc instead of alloc/clear --- 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);