]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Use posix_memalign instead of mm_malloc on non-Windows systems.
authorKen Steele <ken@tilera.com>
Wed, 2 Jul 2014 13:57:31 +0000 (09:57 -0400)
committerKen Steele <ken@tilera.com>
Mon, 21 Jul 2014 18:48:31 +0000 (14:48 -0400)
src/util-mem.h

index aaabd0158ce5ac8e14cdfaabb9aab7eaf5a115c6..b720ac361781ffd17e5dd5b3587d82a99bb81b38 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2013 Open Information Security Foundation
+/* Copyright (C) 2007-2014 Open Information Security Foundation
  *
  * You can copy, redistribute or modify this Program under the terms of
  * the GNU General Public License version 2 as published by the Free
@@ -277,8 +277,12 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
 #define SCMallocAligned(a, b) ({ \
     void *ptrmem = NULL; \
     \
-    ptrmem = _mm_malloc((a), (b)); \
-    if (ptrmem == NULL) { \
+    int r = posix_memalign(&ptrmem, (b), (a)); \
+    if (r != 0 || ptrmem == NULL) { \
+        if (ptrmem != NULL) { \
+            free(ptrmem); \
+            ptrmem = NULL; \
+        } \
         if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
             SCLogError(SC_ERR_MEM_ALLOC, "SCMallocAligned(posix_memalign) failed: %s, while trying " \
                 "to allocate %"PRIuMAX" bytes, alignment %"PRIuMAX, strerror(errno), (uintmax_t)a, (uintmax_t)b); \
@@ -296,7 +300,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
  * _mm_free.
  */
 #define SCFreeAligned(a) ({ \
-    _mm_free((a)); \
+    free(a); \
 })
 
 #endif /* __WIN32 */