From: Ken Steele Date: Wed, 2 Jul 2014 13:57:31 +0000 (-0400) Subject: Use posix_memalign instead of mm_malloc on non-Windows systems. X-Git-Tag: suricata-2.1beta1~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1a7e76ca7186007db73d49562d92249bc91ac93;p=thirdparty%2Fsuricata.git Use posix_memalign instead of mm_malloc on non-Windows systems. --- diff --git a/src/util-mem.h b/src/util-mem.h index aaabd0158c..b720ac3617 100644 --- a/src/util-mem.h +++ b/src/util-mem.h @@ -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 */