|
|
|
|
@ -32,8 +32,10 @@ void *SCMallocFunc(const size_t sz)
|
|
|
|
|
if (unlikely(ptrmem == NULL)) {
|
|
|
|
|
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
|
|
|
|
|
uintmax_t scmalloc_size_ = (uintmax_t)sz;
|
|
|
|
|
SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying "
|
|
|
|
|
"to allocate %"PRIuMAX" bytes", strerror(errno), scmalloc_size_);
|
|
|
|
|
SCLogError(SC_ENOMEM,
|
|
|
|
|
"SCMalloc failed: %s, while trying "
|
|
|
|
|
"to allocate %" PRIuMAX " bytes",
|
|
|
|
|
strerror(errno), scmalloc_size_);
|
|
|
|
|
FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -45,8 +47,10 @@ void *SCReallocFunc(void *ptr, const size_t size)
|
|
|
|
|
void *ptrmem = realloc(ptr, size);
|
|
|
|
|
if (unlikely(ptrmem == NULL)) {
|
|
|
|
|
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
|
|
|
|
|
SCLogError(SC_ERR_MEM_ALLOC, "SCRealloc failed: %s, while trying "
|
|
|
|
|
"to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)size);
|
|
|
|
|
SCLogError(SC_ENOMEM,
|
|
|
|
|
"SCRealloc failed: %s, while trying "
|
|
|
|
|
"to allocate %" PRIuMAX " bytes",
|
|
|
|
|
strerror(errno), (uintmax_t)size);
|
|
|
|
|
FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -58,8 +62,10 @@ void *SCCallocFunc(const size_t nm, const size_t sz)
|
|
|
|
|
void *ptrmem = calloc(nm, sz);
|
|
|
|
|
if (unlikely(ptrmem == NULL)) {
|
|
|
|
|
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
|
|
|
|
|
SCLogError(SC_ERR_MEM_ALLOC, "SCCalloc failed: %s, while trying "
|
|
|
|
|
"to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)nm*sz);
|
|
|
|
|
SCLogError(SC_ENOMEM,
|
|
|
|
|
"SCCalloc failed: %s, while trying "
|
|
|
|
|
"to allocate %" PRIuMAX " bytes",
|
|
|
|
|
strerror(errno), (uintmax_t)nm * sz);
|
|
|
|
|
FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -72,8 +78,10 @@ char *SCStrdupFunc(const char *s)
|
|
|
|
|
if (unlikely(ptrmem == NULL)) {
|
|
|
|
|
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
|
|
|
|
|
size_t _scstrdup_len = strlen(s);
|
|
|
|
|
SCLogError(SC_ERR_MEM_ALLOC, "SCStrdup failed: %s, while trying "
|
|
|
|
|
"to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)_scstrdup_len);
|
|
|
|
|
SCLogError(SC_ENOMEM,
|
|
|
|
|
"SCStrdup failed: %s, while trying "
|
|
|
|
|
"to allocate %" PRIuMAX " bytes",
|
|
|
|
|
strerror(errno), (uintmax_t)_scstrdup_len);
|
|
|
|
|
FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -93,8 +101,10 @@ char *SCStrndupFunc(const char *s, size_t n)
|
|
|
|
|
#endif
|
|
|
|
|
if (unlikely(ptrmem == NULL)) {
|
|
|
|
|
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {
|
|
|
|
|
SCLogError(SC_ERR_MEM_ALLOC, "SCStrndup failed: %s, while trying "
|
|
|
|
|
"to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)(n + 1));
|
|
|
|
|
SCLogError(SC_ENOMEM,
|
|
|
|
|
"SCStrndup failed: %s, while trying "
|
|
|
|
|
"to allocate %" PRIuMAX " bytes",
|
|
|
|
|
strerror(errno), (uintmax_t)(n + 1));
|
|
|
|
|
FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -107,8 +117,10 @@ void *SCMallocAlignedFunc(const size_t size, const size_t align)
|
|
|
|
|
void *ptrmem = _mm_malloc(size, align);
|
|
|
|
|
if (unlikely(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)size, (uintmax_t)align);
|
|
|
|
|
SCLogError(SC_ENOMEM,
|
|
|
|
|
"SCMallocAligned(posix_memalign) failed: %s, while trying "
|
|
|
|
|
"to allocate %" PRIuMAX " bytes, alignment %" PRIuMAX,
|
|
|
|
|
strerror(errno), (uintmax_t)size, (uintmax_t)align);
|
|
|
|
|
FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -121,8 +133,10 @@ void *SCMallocAlignedFunc(const size_t size, const size_t align)
|
|
|
|
|
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)size, (uintmax_t)align);
|
|
|
|
|
SCLogError(SC_ENOMEM,
|
|
|
|
|
"SCMallocAligned(posix_memalign) failed: %s, while trying "
|
|
|
|
|
"to allocate %" PRIuMAX " bytes, alignment %" PRIuMAX,
|
|
|
|
|
strerror(errno), (uintmax_t)size, (uintmax_t)align);
|
|
|
|
|
FatalError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting...");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|