23 #if defined(_WIN32) || defined(__WIN32)
24 #include <mm_malloc.h>
31 void *ptrmem = malloc(sz);
34 uintmax_t scmalloc_size_ = (uintmax_t)sz;
35 SCLogError(
"SCMalloc failed: %s, while trying "
36 "to allocate %" PRIuMAX
" bytes",
37 strerror(errno), scmalloc_size_);
38 FatalError(
"Out of memory. The engine cannot be initialized. Exiting...");
46 void *ptrmem = realloc(ptr,
size);
49 SCLogError(
"SCRealloc failed: %s, while trying "
50 "to allocate %" PRIuMAX
" bytes",
51 strerror(errno), (uintmax_t)
size);
52 FatalError(
"Out of memory. The engine cannot be initialized. Exiting...");
60 void *ptrmem = calloc(nm, sz);
63 SCLogError(
"SCCalloc failed: %s, while trying "
64 "to allocate %" PRIuMAX
" bytes",
65 strerror(errno), (uintmax_t)nm * sz);
66 FatalError(
"Out of memory. The engine cannot be initialized. Exiting...");
74 char *ptrmem = strdup(s);
77 size_t _scstrdup_len = strlen(s);
78 SCLogError(
"SCStrdup failed: %s, while trying "
79 "to allocate %" PRIuMAX
" bytes",
80 strerror(errno), (uintmax_t)_scstrdup_len);
81 FatalError(
"Out of memory. The engine cannot be initialized. Exiting...");
90 char *ptrmem = strndup(s, n);
92 const size_t sz = n + 1;
93 char *ptrmem = (
char *)malloc(sz);
94 if (
likely(ptrmem != NULL)) {
100 SCLogError(
"SCStrndup failed: %s, while trying "
101 "to allocate %" PRIuMAX
" bytes",
102 strerror(errno), (uintmax_t)(n + 1));
103 FatalError(
"Out of memory. The engine cannot be initialized. Exiting...");
111 #if defined(__WIN32) || defined(_WIN32)
112 void *ptrmem = _mm_malloc(
size, align);
115 SCLogError(
"SCMallocAligned(posix_memalign) failed: %s, while trying "
116 "to allocate %" PRIuMAX
" bytes, alignment %" PRIuMAX,
117 strerror(errno), (uintmax_t)
size, (uintmax_t)align);
118 FatalError(
"Out of memory. The engine cannot be initialized. Exiting...");
123 int r = posix_memalign(&ptrmem, align,
size);
124 if (
unlikely(r != 0 || ptrmem == NULL)) {
125 if (ptrmem != NULL) {
130 SCLogError(
"SCMallocAligned(posix_memalign) failed: %s, while trying "
131 "to allocate %" PRIuMAX
" bytes, alignment %" PRIuMAX,
132 strerror(errno), (uintmax_t)
size, (uintmax_t)align);
133 FatalError(
"Out of memory. The engine cannot be initialized. Exiting...");
142 #if defined(__WIN32) || defined(_WIN32)