* \retval tx or NULL */
DNSTransaction *DNSTransactionAlloc(const uint16_t tx_id) {
DNSTransaction *tx = SCMalloc(sizeof(DNSTransaction));
- if (tx == NULL)
+ if (unlikely(tx == NULL))
return NULL;
memset(tx, 0x00, sizeof(DNSTransaction));
}
DNSQueryEntry *q = SCMalloc(sizeof(DNSQueryEntry) + fqdn_len);
- if (q == NULL)
+ if (unlikely(q == NULL))
return;
q->type = type;
q->class = class;
}
DNSAnswerEntry *q = SCMalloc(sizeof(DNSAnswerEntry) + fqdn_len + data_len);
- if (q == NULL)
+ if (unlikely(q == NULL))
return;
q->type = type;
q->class = class;
return HTP_OK;
tx_ud = SCMalloc(sizeof(*tx_ud));
- if (tx_ud == NULL) {
+ if (unlikely(tx_ud == NULL)) {
bstr_free(request_uri_normalized);
return HTP_OK;
}
HtpTxUserData *tx_ud = htp_tx_get_user_data(tx_data->tx);
if (tx_ud == NULL) {
tx_ud = SCMalloc(sizeof(*tx_ud));
- if (tx_ud == NULL)
+ if (unlikely(tx_ud == NULL))
return HTP_OK;
memset(tx_ud, 0, sizeof(*tx_ud));
htp_tx_set_user_data(tx_data->tx, tx_ud);
HtpTxUserData *tx_ud = htp_tx_get_user_data(tx_data->tx);
if (tx_ud == NULL) {
tx_ud = SCMalloc(sizeof(*tx_ud));
- if (tx_ud == NULL)
+ if (unlikely(tx_ud == NULL))
return HTP_OK;
memset(tx_ud, 0, sizeof(*tx_ud));
htp_tx_set_user_data(tx_data->tx, tx_ud);
HTPConfigure();
httpbuf = SCMalloc(len);
- if (httpbuf == NULL)
+ if (unlikely(httpbuf == NULL))
goto end;
memset(httpbuf, 0x00, len);
static inline AppLayerProbingParserElement *AllocAppLayerProbingParserElement(void)
{
AppLayerProbingParserElement *p = SCMalloc(sizeof(AppLayerProbingParserElement));
- if (p == NULL) {
+ if (unlikely(p == NULL)) {
exit(EXIT_FAILURE);
}
memset(p, 0, sizeof(AppLayerProbingParserElement));
static inline AppLayerProbingParserPort *AllocAppLayerProbingParserPort(void)
{
AppLayerProbingParserPort *p = SCMalloc(sizeof(AppLayerProbingParserPort));
- if (p == NULL) {
+ if (unlikely(p == NULL)) {
exit(EXIT_FAILURE);
}
memset(p, 0, sizeof(AppLayerProbingParserPort));
static inline AppLayerProbingParser *AllocAppLayerProbingParser(void)
{
AppLayerProbingParser *p = SCMalloc(sizeof(AppLayerProbingParser));
- if (p == NULL) {
+ if (unlikely(p == NULL)) {
exit(EXIT_FAILURE);
}
memset(p, 0, sizeof(AppLayerProbingParser));
DetectContentData *cd = NULL;
int patlen = 257;
char *teststring = SCMalloc(sizeof(char) * (patlen + 1));
- if (teststring == NULL)
+ if (unlikely(teststring == NULL))
return 0;
int idx = 0;
teststring[idx++] = '\"';
DetectContentData *cd = NULL;
int patlen = 258;
char *teststring = SCMalloc(sizeof(char) * (patlen + 1));
- if (teststring == NULL)
+ if (unlikely(teststring == NULL))
return 0;
int idx = 0;
teststring[idx++] = '\"';
DetectContentData *cd = NULL;
int patlen = 260;
char *teststring = SCMalloc(sizeof(char) * (patlen + 1));
- if (teststring == NULL)
+ if (unlikely(teststring == NULL))
return 0;
int idx = 0;
teststring[idx++] = '\"';
DetectContentData *cd = NULL;
int patlen = 261;
char *teststring = SCMalloc(sizeof(char) * (patlen + 1));
- if (teststring == NULL)
+ if (unlikely(teststring == NULL))
return 0;
int idx = 0;
teststring[idx++] = '\"';
#define TOTAL_REQUESTS 45
uint8_t *http_buf = SCMalloc(TOTAL_REQUESTS * strlen(request_buffer));
- if (http_buf == NULL)
+ if (unlikely(http_buf == NULL))
goto end;
for (int i = 0; i < TOTAL_REQUESTS; i++) {
memcpy(http_buf + i * strlen(request_buffer), request_buffer,
/* the extra 4 bytes if for ": " and "\r\n" */
headers_buffer = SCRealloc(headers_buffer, headers_buffer_len + size1 + size2 + 4);
- if (headers_buffer == NULL) {
+ if (unlikely(headers_buffer == NULL)) {
det_ctx->hhd_buffers[index] = NULL;
det_ctx->hhd_buffers_len[index] = 0;
goto end;
/* array hash buffer - i've run out of ideas to name it */
uint8_t *ahb = SCMalloc(sizeof(uint8_t) * (struct_total_size + content_total_size));
- if (ahb == NULL)
+ if (unlikely(ahb == NULL))
return -1;
uint8_t *content = NULL;
}
buffer = SCMalloc(len+1);
- if (buffer == NULL) {
+ if (unlikely(buffer == NULL)) {
lua_pushnil(luastate);
lua_pushstring(luastate, "out of memory");
return 2;
}
void *ptr1a = SCMalloc(128);
- if (ptr1a == NULL) {
+ if (unlikely(ptr1a == NULL)) {
goto error;
}
FlowSetStorageById(f, id1, ptr1a);
}
void *ptr1a = SCMalloc(128);
- if (ptr1a == NULL) {
+ if (unlikely(ptr1a == NULL)) {
goto error;
}
FlowSetStorageById(f, id1, ptr1a);
void *ptr2a = SCMalloc(256);
- if (ptr2a == NULL) {
+ if (unlikely(ptr2a == NULL)) {
goto error;
}
FlowSetStorageById(f, id2, ptr2a);
}
void *ptr1a = SCMalloc(128);
- if (ptr1a == NULL) {
+ if (unlikely(ptr1a == NULL)) {
goto error;
}
HostSetStorageById(h, id1, ptr1a);
}
void *ptr1a = SCMalloc(128);
- if (ptr1a == NULL) {
+ if (unlikely(ptr1a == NULL)) {
goto error;
}
HostSetStorageById(h, id1, ptr1a);
void *ptr2a = SCMalloc(256);
- if (ptr2a == NULL) {
+ if (unlikely(ptr2a == NULL)) {
goto error;
}
HostSetStorageById(h, id2, ptr2a);
char *copymodestr;
char *out_iface = NULL;
- if (aconf == NULL) {
+ if (unlikely(aconf == NULL)) {
return NULL;
}
} else {
mpipe_devc = SCStrdup(mpipe_dev);
}
- if (mpipe_devc == NULL) {
+ if (unlikely(mpipe_devc == NULL)) {
printf("ERROR: SCStrdup failed for ReceiveMpipe\n");
exit(EXIT_FAILURE);
}
snprintf(tname, sizeof(tname), "Worker%d", pipe+1);
thread_name = SCStrdup(tname);
- if (thread_name == NULL) {
+ if (unlikely(thread_name == NULL)) {
printf("ERROR: SCStrdup failed for ReceiveMpipe\n");
exit(EXIT_FAILURE);
}
}
MpipeThreadVars *ptv = SCMalloc(sizeof(MpipeThreadVars));
- if (ptv == NULL)
+ if (unlikely(ptv == NULL))
SCReturnInt(TM_ECODE_FAILED);
memset(ptv, 0, sizeof(MpipeThreadVars));
/* Allocate some ingress queues. */
iqueues = SCCalloc(num_workers, sizeof(*iqueues));
- if (iqueues == NULL)
+ if (unlikely(iqueues == NULL))
SCReturnInt(TM_ECODE_FAILED);
/* Allocate some NotifRings. */
int MpipeLiveRegisterDevice(char *dev)
{
MpipeDevice *nd = SCMalloc(sizeof(MpipeDevice));
- if (nd == NULL) {
+ if (unlikely(nd == NULL)) {
return -1;
}
SCLogInfo("Napatech Thread Stream ID:%lu", stream_id);
NapatechThreadVars *ntv = SCMalloc(sizeof(NapatechThreadVars));
- if (ntv == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "Failed to allocate memory for NAPATECH thread vars.");
+ if (unlikely(ntv == NULL)) {
+ SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for NAPATECH thread vars.");
exit(EXIT_FAILURE);
}
}
TcpStateQueue *q = SCMalloc(sizeof(*q));
- if (q == NULL) {
+ if (unlikely(q == NULL)) {
SCLogDebug("ssn %p: =~ SYN/ACK queue failed: alloc failed", ssn);
return -1;
}
}
CudaBufferData *new = SCMalloc(sizeof(CudaBufferData));
- if (new == NULL) {
+ if (unlikely(new == NULL)) {
return NULL;
}
memset(new, 0, sizeof(CudaBufferData));
static void *CudaBufferSlicePoolAlloc(void *null)
{
void *ptr = SCMalloc(sizeof(CudaBufferSlice));
- if (ptr == NULL)
+ if (unlikely(ptr == NULL))
return NULL;
memset(ptr, 0, sizeof(CudaBufferSlice));
}
CudaHandlerConfProfile *new_cp = SCMalloc(sizeof(CudaHandlerConfProfile));
- if (new_cp == NULL)
+ if (unlikely(new_cp == NULL))
exit(EXIT_FAILURE);
memset(new_cp, 0, sizeof(CudaHandlerConfProfile));
new_cp->name = SCStrdup(name);
}
CudaHandlerModule *new_module = SCMalloc(sizeof(CudaHandlerModule));
- if (new_module == NULL)
+ if (unlikely(new_module == NULL))
exit(EXIT_FAILURE);
memset(new_module, 0, sizeof(CudaHandlerModule));
new_module->device_id = device_id;
if (no_of_cuda_contexts <= device_id) {
cuda_contexts = SCRealloc(cuda_contexts, sizeof(CUcontext) * (device_id + 1));
- if (cuda_contexts == NULL)
+ if (unlikely(cuda_contexts == NULL))
exit(EXIT_FAILURE);
memset(cuda_contexts + no_of_cuda_contexts, 0,
sizeof(CUcontext) * ((device_id + 1) - no_of_cuda_contexts));
}
CudaHandlerModuleData *new_data = SCMalloc(sizeof(CudaHandlerModuleData));
- if (new_data == NULL)
+ if (unlikely(new_data == NULL))
exit(EXIT_FAILURE);
memset(new_data, 0, sizeof(CudaHandlerModuleData));
new_data->name = SCStrdup(data_name);
static SCCudaDevice *SCCudaAllocSCCudaDevice(void)
{
SCCudaDevice *device = SCMalloc(sizeof(SCCudaDevice));
- if (device == NULL)
+ if (unlikely(device == NULL))
return NULL;
memset(device, 0 , sizeof(SCCudaDevice));
static SCCudaDevices *SCCudaAllocSCCudaDevices(void)
{
SCCudaDevices *devices = SCMalloc(sizeof(SCCudaDevices));
- if (devices == NULL)
+ if (unlikely(devices == NULL))
return NULL;
memset(devices, 0 , sizeof(SCCudaDevices));
result = magic_buffer(g_magic_ctx, (void *)buf, (size_t)buflen);
if (result != NULL) {
magic = SCStrdup(result);
- if (magic == NULL) {
+ if (unlikely(magic == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Unable to dup magic");
}
}
result = magic_buffer(*ctx, (void *)buf, (size_t)buflen);
if (result != NULL) {
magic = SCStrdup(result);
- if (magic == NULL) {
+ if (unlikely(magic == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Unable to dup magic");
}
}
}
int size = ctx->state_count * sizeof(SC_AC_TILE_STATE_TYPE_U16) * alpha_size;
SC_AC_TILE_STATE_TYPE_U16 *state_table = SCMalloc(size);
- if (state_table == NULL) {
+ if (unlikely(state_table == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
/* let's make the new entry */
items = SCRealloc(items,
(de_ctx->mpm_ctx_factory_container->no_of_items + 1) * sizeof(MpmCtxFactoryItem));
- if (items == NULL) {
+ if (unlikely(items == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
const char *value;
MpmCudaConf *conf = SCMalloc(sizeof(MpmCudaConf));
- if (conf == NULL)
+ if (unlikely(conf == NULL))
exit(EXIT_FAILURE);
memset(conf, 0, sizeof(*conf));
}
pt = SCMalloc(sizeof(*pt));
- if (pt == NULL) {
+ if (unlikely(pt == NULL)) {
SCLogDebug("memory alloc error");
goto error;
}
char qname[TM_QUEUE_NAME_MAX];
queues = SCMalloc(queues_size);
- if (queues == NULL) {
+ if (unlikely(queues == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "failed to alloc queues buffer: %s", strerror(errno));
return NULL;
}
}
StorageList *entry = SCMalloc(sizeof(StorageList));
- if (entry == NULL)
+ if (unlikely(entry == NULL))
return -1;
memset(entry, 0x00, sizeof(StorageList));
return 0;
storage_map = SCMalloc(sizeof(StorageMapping *) * STORAGE_MAX);
- if (storage_map == NULL) {
+ if (unlikely(storage_map == NULL)) {
return -1;
}
memset(storage_map, 0x00, sizeof(StorageMapping *) * STORAGE_MAX);
Storage *store = *storage;
if (store == NULL) {
store = SCMalloc(sizeof(void *) * storage_max_id[type]);
- if (store == NULL)
- return NULL;
+ if (unlikely(store == NULL))
+ return NULL;
memset(store, 0x00, sizeof(void *) * storage_max_id[type]);
}
SCLogDebug("store %p", store);
else
line = SCRealloc(line, strlen(line) + len + 1);
- if (line == NULL) {
+ if (unlikely(line == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
break;
}