]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
htp: add HTPCalloc wrapper
authorVictor Julien <victor@inliniac.net>
Fri, 13 Nov 2015 16:11:08 +0000 (17:11 +0100)
committerVictor Julien <victor@inliniac.net>
Wed, 2 Mar 2016 09:00:48 +0000 (10:00 +0100)
src/app-layer-htp-mem.c
src/app-layer-htp-mem.h

index c4f94e826ee723b59d6ee83a6222c5f19a80ee9e..c9caefa2dffe8f42186773b63478619bb379da78 100644 (file)
@@ -121,6 +121,23 @@ void *HTPMalloc(size_t size)
     return ptr;
 }
 
+void *HTPCalloc(size_t n, size_t size)
+{
+    void *ptr = NULL;
+
+    if (HTPCheckMemcap((uint32_t)(n * size)) == 0)
+        return NULL;
+
+    ptr = SCCalloc(n, size);
+
+    if (unlikely(ptr == NULL))
+        return NULL;
+
+    HTPIncrMemuse((uint64_t)(n * size));
+
+    return ptr;
+}
+
 void *HTPRealloc(void *ptr, size_t orig_size, size_t size)
 {
     void *rptr = NULL;
index 44b50f5c084896f380b458c06de4355d6f490ac0..1039c32ce611fc6621ba98684984c148d82c72b5 100644 (file)
@@ -19,6 +19,7 @@
 
 void HTPParseMemcap();
 void *HTPMalloc(size_t size);
+void *HTPCalloc(size_t n, size_t size);
 void *HTPRealloc(void *ptr, size_t orig_size, size_t size);
 void HTPFree(void *ptr, size_t size);