From: Philippe Antoine Date: Fri, 20 May 2022 18:24:43 +0000 (+0200) Subject: util: remove malloc from streaming buffer config X-Git-Tag: suricata-7.0.0-beta1~532 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5bd19135b04832919e3776c2cfb4eec66f8ab272;p=thirdparty%2Fsuricata.git util: remove malloc from streaming buffer config as it is unused --- diff --git a/src/app-layer-ftp.c b/src/app-layer-ftp.c index 7bae47df74..79a7836af6 100644 --- a/src/app-layer-ftp.c +++ b/src/app-layer-ftp.c @@ -1391,7 +1391,6 @@ void RegisterFTPParsers(void) ALPROTO_FTPDATA, FTPDATA_STATE_FINISHED, FTPDATA_STATE_FINISHED); sbcfg.buf_size = 4096; - sbcfg.Malloc = FTPMalloc; sbcfg.Calloc = FTPCalloc; sbcfg.Realloc = FTPRealloc; sbcfg.Free = FTPFree; diff --git a/src/app-layer-htp-body.c b/src/app-layer-htp-body.c index b3042623c2..524aed3578 100644 --- a/src/app-layer-htp-body.c +++ b/src/app-layer-htp-body.c @@ -63,7 +63,7 @@ #include "util-memcmp.h" -static StreamingBufferConfig default_cfg = { 0, 3072, HTPMalloc, HTPCalloc, HTPRealloc, HTPFree }; +static StreamingBufferConfig default_cfg = { 0, 3072, HTPCalloc, HTPRealloc, HTPFree }; /** * \brief Append a chunk of body to the HtpBody struct diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index c6cb2bc794..fc75338373 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -2538,7 +2538,6 @@ static void HTPConfigSetDefaultsPhase2(const char *name, HTPCfgRec *cfg_prec) cfg_prec->request.sbcfg.buf_size = cfg_prec->request.inspect_window ? cfg_prec->request.inspect_window : 256; cfg_prec->request.sbcfg.buf_slide = 0; - cfg_prec->request.sbcfg.Malloc = HTPMalloc; cfg_prec->request.sbcfg.Calloc = HTPCalloc; cfg_prec->request.sbcfg.Realloc = HTPRealloc; cfg_prec->request.sbcfg.Free = HTPFree; @@ -2546,7 +2545,6 @@ static void HTPConfigSetDefaultsPhase2(const char *name, HTPCfgRec *cfg_prec) cfg_prec->response.sbcfg.buf_size = cfg_prec->response.inspect_window ? cfg_prec->response.inspect_window : 256; cfg_prec->response.sbcfg.buf_slide = 0; - cfg_prec->response.sbcfg.Malloc = HTPMalloc; cfg_prec->response.sbcfg.Calloc = HTPCalloc; cfg_prec->response.sbcfg.Realloc = HTPRealloc; cfg_prec->response.sbcfg.Free = HTPFree; diff --git a/src/stream-tcp-reassemble.c b/src/stream-tcp-reassemble.c index a01d8f72cb..3b8b7c3afa 100644 --- a/src/stream-tcp-reassemble.c +++ b/src/stream-tcp-reassemble.c @@ -193,20 +193,6 @@ uint64_t StreamTcpReassembleGetMemcap() /* memory functions for the streaming buffer API */ -/* - void *(*Malloc)(size_t size); -*/ -static void *ReassembleMalloc(size_t size) -{ - if (StreamTcpReassembleCheckMemcap(size) == 0) - return NULL; - void *ptr = SCMalloc(size); - if (ptr == NULL) - return NULL; - StreamTcpReassembleIncrMemuse(size); - return ptr; -} - /* void *(*Calloc)(size_t n, size_t size); */ @@ -484,7 +470,6 @@ static int StreamTcpReassemblyConfig(bool quiet) } stream_config.sbcnf.buf_size = 2048; - stream_config.sbcnf.Malloc = ReassembleMalloc; stream_config.sbcnf.Calloc = ReassembleCalloc; stream_config.sbcnf.Realloc = StreamTcpReassembleRealloc; stream_config.sbcnf.Free = ReassembleFree; diff --git a/src/util-streaming-buffer.c b/src/util-streaming-buffer.c index b60b696f32..d4c3632037 100644 --- a/src/util-streaming-buffer.c +++ b/src/util-streaming-buffer.c @@ -31,8 +31,6 @@ /* memory handling wrappers. If config doesn't define it's own set of * functions, use the defaults */ -#define MALLOC(cfg, s) \ - (cfg)->Malloc ? (cfg)->Malloc((s)) : SCMalloc((s)) #define CALLOC(cfg, n, s) \ (cfg)->Calloc ? (cfg)->Calloc((n), (s)) : SCCalloc((n), (s)) #define REALLOC(cfg, ptr, orig_s, s) \ @@ -909,7 +907,7 @@ static void DumpSegment(StreamingBuffer *sb, StreamingBufferSegment *seg) static int StreamingBufferTest02(void) { - StreamingBufferConfig cfg = { 8, 24, NULL, NULL, NULL, NULL }; + StreamingBufferConfig cfg = { 8, 24, NULL, NULL, NULL }; StreamingBuffer *sb = StreamingBufferInit(&cfg); FAIL_IF(sb == NULL); @@ -965,7 +963,7 @@ static int StreamingBufferTest02(void) static int StreamingBufferTest03(void) { - StreamingBufferConfig cfg = { 8, 24, NULL, NULL, NULL, NULL }; + StreamingBufferConfig cfg = { 8, 24, NULL, NULL, NULL }; StreamingBuffer *sb = StreamingBufferInit(&cfg); FAIL_IF(sb == NULL); @@ -1020,7 +1018,7 @@ static int StreamingBufferTest03(void) static int StreamingBufferTest04(void) { - StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL, NULL }; + StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL }; StreamingBuffer *sb = StreamingBufferInit(&cfg); FAIL_IF(sb == NULL); @@ -1111,7 +1109,7 @@ static int StreamingBufferTest04(void) /** \test lots of gaps in block list */ static int StreamingBufferTest06(void) { - StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL, NULL }; + StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL }; StreamingBuffer *sb = StreamingBufferInit(&cfg); FAIL_IF(sb == NULL); @@ -1169,7 +1167,7 @@ static int StreamingBufferTest06(void) /** \test lots of gaps in block list */ static int StreamingBufferTest07(void) { - StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL, NULL }; + StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL }; StreamingBuffer *sb = StreamingBufferInit(&cfg); FAIL_IF(sb == NULL); @@ -1227,7 +1225,7 @@ static int StreamingBufferTest07(void) /** \test lots of gaps in block list */ static int StreamingBufferTest08(void) { - StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL, NULL }; + StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL }; StreamingBuffer *sb = StreamingBufferInit(&cfg); FAIL_IF(sb == NULL); @@ -1285,7 +1283,7 @@ static int StreamingBufferTest08(void) /** \test lots of gaps in block list */ static int StreamingBufferTest09(void) { - StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL, NULL }; + StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL }; StreamingBuffer *sb = StreamingBufferInit(&cfg); FAIL_IF(sb == NULL); @@ -1343,7 +1341,7 @@ static int StreamingBufferTest09(void) /** \test lots of gaps in block list */ static int StreamingBufferTest10(void) { - StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL, NULL }; + StreamingBufferConfig cfg = { 8, 16, NULL, NULL, NULL }; StreamingBuffer *sb = StreamingBufferInit(&cfg); FAIL_IF(sb == NULL); diff --git a/src/util-streaming-buffer.h b/src/util-streaming-buffer.h index 1680dedf85..fd2a2e2449 100644 --- a/src/util-streaming-buffer.h +++ b/src/util-streaming-buffer.h @@ -64,7 +64,6 @@ typedef struct StreamingBufferConfig_ { uint32_t buf_slide; uint32_t buf_size; - void *(*Malloc)(size_t size); void *(*Calloc)(size_t n, size_t size); void *(*Realloc)(void *ptr, size_t orig_size, size_t size); void (*Free)(void *ptr, size_t size); @@ -72,7 +71,7 @@ typedef struct StreamingBufferConfig_ { #define STREAMING_BUFFER_CONFIG_INITIALIZER \ { \ - 0, 0, NULL, NULL, NULL, NULL, \ + 0, 0, NULL, NULL, NULL, \ } /**