22 #if defined(_WIN32) || defined(__WIN32)
23 #include <mm_malloc.h>
30 void *ptrmem = malloc(sz);
33 uintmax_t scmalloc_size_ = (uintmax_t)sz;
34 SCLogError(
"SCMalloc failed: %s, while trying "
35 "to allocate %" PRIuMAX
" bytes",
36 strerror(errno), scmalloc_size_);
37 FatalError(
"Out of memory. The engine cannot be initialized. Exiting...");
45 void *ptrmem = realloc(ptr,
size);
48 SCLogError(
"SCRealloc failed: %s, while trying "
49 "to allocate %" PRIuMAX
" bytes",
50 strerror(errno), (uintmax_t)
size);
51 FatalError(
"Out of memory. The engine cannot be initialized. Exiting...");
59 void *ptrmem = calloc(nm, sz);
62 SCLogError(
"SCCalloc failed: %s, while trying "
63 "to allocate %" PRIuMAX
" bytes",
64 strerror(errno), (uintmax_t)nm * sz);
65 FatalError(
"Out of memory. The engine cannot be initialized. Exiting...");
73 char *ptrmem = strdup(s);
76 size_t _scstrdup_len = strlen(s);
77 SCLogError(
"SCStrdup failed: %s, while trying "
78 "to allocate %" PRIuMAX
" bytes",
79 strerror(errno), (uintmax_t)_scstrdup_len);
80 FatalError(
"Out of memory. The engine cannot be initialized. Exiting...");
89 char *ptrmem = strndup(s, n);
91 const size_t sz = n + 1;
92 char *ptrmem = (
char *)malloc(sz);
93 if (
likely(ptrmem != NULL)) {
99 SCLogError(
"SCStrndup failed: %s, while trying "
100 "to allocate %" PRIuMAX
" bytes",
101 strerror(errno), (uintmax_t)(n + 1));
102 FatalError(
"Out of memory. The engine cannot be initialized. Exiting...");
110 #if defined(__WIN32) || defined(_WIN32)
111 void *ptrmem = _mm_malloc(
size, align);
114 SCLogError(
"SCMallocAligned(posix_memalign) failed: %s, while trying "
115 "to allocate %" PRIuMAX
" bytes, alignment %" PRIuMAX,
116 strerror(errno), (uintmax_t)
size, (uintmax_t)align);
117 FatalError(
"Out of memory. The engine cannot be initialized. Exiting...");
122 int r = posix_memalign(&ptrmem, align,
size);
123 if (
unlikely(r != 0 || ptrmem == NULL)) {
124 if (ptrmem != NULL) {
129 SCLogError(
"SCMallocAligned(posix_memalign) failed: %s, while trying "
130 "to allocate %" PRIuMAX
" bytes, alignment %" PRIuMAX,
131 strerror(errno), (uintmax_t)
size, (uintmax_t)align);
132 FatalError(
"Out of memory. The engine cannot be initialized. Exiting...");
141 #if defined(__WIN32) || defined(_WIN32)