23#if defined(_WIN32) || defined(__WIN32)
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)
size_t strlcpy(char *dst, const char *src, size_t siz)
#define SC_ATOMIC_EXTERN(type, name)
wrapper for referencing an atomic variable declared on another file.
#define SC_ATOMIC_GET(name)
Get the value from the atomic variable.
#define SCLogError(...)
Macro used to log ERROR messages.
void SCFreeAlignedFunc(void *ptr)
Free aligned memory.
char * SCStrdupFunc(const char *s)
void * SCReallocFunc(void *ptr, const size_t size)
void * SCMallocAlignedFunc(const size_t size, const size_t align)
wrapper for allocing aligned mem
void * SCMallocFunc(const size_t sz)
char * SCStrndupFunc(const char *s, size_t n)
void * SCCallocFunc(const size_t nm, const size_t sz)