TmEcode AlertDebugLogThreadInit(ThreadVars *t, void *initdata, void **data)
{
AlertDebugLogThread *aft = SCMalloc(sizeof(AlertDebugLogThread));
- if (aft == NULL)
+ if (unlikely(aft == NULL))
return TM_ECODE_FAILED;
memset(aft, 0, sizeof(AlertDebugLogThread));
}
OutputCtx *output_ctx = SCMalloc(sizeof(OutputCtx));
- if (output_ctx == NULL)
+ if (unlikely(output_ctx == NULL))
goto error;
memset(output_ctx, 0x00, sizeof(OutputCtx));
TmEcode AlertFastLogThreadInit(ThreadVars *t, void *initdata, void **data)
{
AlertFastLogThread *aft = SCMalloc(sizeof(AlertFastLogThread));
- if (aft == NULL)
+ if (unlikely(aft == NULL))
return TM_ECODE_FAILED;
memset(aft, 0, sizeof(AlertFastLogThread));
if(initdata == NULL)
}
OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
- if (output_ctx == NULL)
+ if (unlikely(output_ctx == NULL))
return NULL;
output_ctx->data = logfile_ctx;
output_ctx->DeInit = AlertFastLogDeInitCtx;
TmEcode AlertPcapInfoThreadInit(ThreadVars *t, void *initdata, void **data)
{
AlertPcapInfoThread *aft = SCMalloc(sizeof(AlertPcapInfoThread));
- if (aft == NULL)
+ if (unlikely(aft == NULL))
return TM_ECODE_FAILED;
memset(aft, 0, sizeof(AlertPcapInfoThread));
if(initdata == NULL)
}
OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
- if (output_ctx == NULL)
+ if (unlikely(output_ctx == NULL))
return NULL;
output_ctx->data = logfile_ctx;
output_ctx->DeInit = AlertPcapInfoDeInitCtx;
}
aun = SCMalloc(sizeof(AlertPreludeThread));
- if (aun == NULL)
+ if (unlikely(aun == NULL))
SCReturnInt(TM_ECODE_FAILED);
memset(aun, 0, sizeof(AlertPreludeThread));
}
ctx = SCMalloc(sizeof(AlertPreludeCtx));
- if ( ctx == NULL ) {
+ if (unlikely(ctx == NULL)) {
prelude_perror(ret, "Unable to allocate memory");
prelude_client_destroy(client, PRELUDE_CLIENT_EXIT_STATUS_SUCCESS);
SCReturnPtr(NULL, "AlertPreludeCtx");
ctx->log_packet_header = 0;
output_ctx = SCMalloc(sizeof(OutputCtx));
- if (output_ctx == NULL) {
+ if (unlikely(output_ctx == NULL)) {
SCFree(ctx);
-
prelude_perror(ret, "Unable to allocate memory");
prelude_client_destroy(client, PRELUDE_CLIENT_EXIT_STATUS_SUCCESS);
SCReturnPtr(NULL, "AlertPreludeCtx");
openlog(ident, LOG_PID|LOG_NDELAY, facility);
OutputCtx *output_ctx = SCMalloc(sizeof(OutputCtx));
- if (output_ctx == NULL) {
+ if (unlikely(output_ctx == NULL)) {
SCLogDebug("AlertSyslogInitCtx: Could not create new OutputCtx");
return NULL;
}
}
AlertSyslogThread *ast = SCMalloc(sizeof(AlertSyslogThread));
- if (ast == NULL)
+ if (unlikely(ast == NULL))
return TM_ECODE_FAILED;
memset(ast, 0, sizeof(AlertSyslogThread));
TmEcode Unified2AlertThreadInit(ThreadVars *t, void *initdata, void **data)
{
Unified2AlertThread *aun = SCMalloc(sizeof(Unified2AlertThread));
- if (aun == NULL)
+ if (unlikely(aun == NULL))
return TM_ECODE_FAILED;
memset(aun, 0, sizeof(Unified2AlertThread));
if(initdata == NULL)
goto error;
OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
- if (output_ctx == NULL)
+ if (unlikely(output_ctx == NULL))
goto error;
output_ctx->data = file_ctx;
output_ctx->DeInit = Unified2AlertDeInitCtx;
0x28, 0x81, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03,
0x03, 0x06};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int ret;
0x08, 0x0a, 0x00, 0x0a, 0x22, 0xa8, 0x00, 0x00,
0x00, 0x00, 0x01, 0x03, 0x03, 0x05 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int ret;
0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x6e, 0x65, 0x74,
0x0d, 0x0a};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int ret;
0x00, 0x00, 0x00, 0x00, 0x60, 0x02, 0x10, 0x20,
0xdd, 0xe1, 0x00, 0x00, 0x02, 0x04, 0x05, 0xb4};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int ret;
0x28, 0x81, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03,
0x03, 0x06};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int ret;
if (lf == NULL)
return 0;
filename = SCStrdup(lf->filename);
- if (filename == NULL)
+ if (unlikely(filename == NULL))
return 0;
memset(&tv, 0, sizeof(ThreadVars));
static void *DCERPCUDPStateAlloc(void) {
void *s = SCMalloc(sizeof(DCERPCUDPState));
- if (s == NULL)
+ if (unlikely(s == NULL))
return NULL;
memset(s, 0, sizeof(DCERPCUDPState));
SCEnter();
DCERPCState *s = SCMalloc(sizeof(DCERPCState));
- if (s == NULL) {
+ if (unlikely(s == NULL)) {
SCReturnPtr(NULL, "void");
}
memset(s, 0, sizeof(DCERPCState));
*/
static void AlpProtoAddSignature(AlpProtoDetectCtx *ctx, DetectContentData *co, uint16_t ip_proto, uint16_t proto) {
AlpProtoSignature *s = SCMalloc(sizeof(AlpProtoSignature));
- if (s == NULL) {
+ if (unlikely(s == NULL)) {
SCLogError(SC_ERR_FATAL, "Error allocating memory. Signature not loaded. Not enough memory so.. exiting..");
exit(EXIT_FAILURE);
}
searchlen);
#else
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
goto end;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
static void *FTPStateAlloc(void) {
void *s = SCMalloc(sizeof(FtpState));
- if (s == NULL)
+ if (unlikely(s == NULL))
return NULL;
memset(s, 0, sizeof(FtpState));
SCEnter();
HtpState *s = SCMalloc(sizeof(HtpState));
- if (s == NULL)
+ if (unlikely(s == NULL))
goto error;
memset(s, 0x00, sizeof(HtpState));
HtpTxUserData *htud = (HtpTxUserData *) htp_tx_get_user_data(d->tx);
if (htud == NULL) {
htud = SCMalloc(sizeof(HtpTxUserData));
- if (htud == NULL) {
+ if (unlikely(htud == NULL)) {
SCReturnInt(HOOK_OK);
}
memset(htud, 0, sizeof(HtpTxUserData));
HtpTxUserData *htud = (HtpTxUserData *) htp_tx_get_user_data(d->tx);
if (htud == NULL) {
htud = SCMalloc(sizeof(HtpTxUserData));
- if (htud == NULL) {
+ if (unlikely(htud == NULL)) {
SCReturnInt(HOOK_OK);
}
memset(htud, 0, sizeof(HtpTxUserData));
(uint8_t *input, uint32_t input_len))
{
AppLayerProbingParserElement *pe = SCMalloc(sizeof(AppLayerProbingParserElement));
- if (pe == NULL) {
+ if (unlikely(pe == NULL)) {
return NULL;
}
AppLayerDuplicateAppLayerProbingParserElement(AppLayerProbingParserElement *pe)
{
AppLayerProbingParserElement *new_pe = SCMalloc(sizeof(AppLayerProbingParserElement));
- if (new_pe == NULL) {
+ if (unlikely(new_pe == NULL)) {
return NULL;
}
{
if (pp == NULL) {
AppLayerProbingParser *new_pp = SCMalloc(sizeof(AppLayerProbingParser));
- if (new_pp == NULL)
+ if (unlikely(new_pp == NULL))
return;
memset(new_pp, 0, sizeof(AppLayerProbingParser));
if (ppi == NULL) {
new_ppi = SCMalloc(sizeof(AppLayerProbingParserInfo));
- if (new_ppi == NULL) {
+ if (unlikely(new_ppi == NULL)) {
return -1;
}
memset(new_ppi, 0, sizeof(AppLayerProbingParserInfo));
static void *TestProtocolStateAlloc(void)
{
void *s = SCMalloc(sizeof(TestState));
- if (s == NULL)
+ if (unlikely(s == NULL))
return NULL;
memset(s, 0, sizeof(TestState));
SCEnter();
void *s = SCMalloc(sizeof(SMBState));
- if (s == NULL) {
+ if (unlikely(s == NULL)) {
SCReturnPtr(NULL, "void");
}
static void *SMB2StateAlloc(void) {
void *s = SCMalloc(sizeof(SMB2State));
- if (s == NULL)
+ if (unlikely(s == NULL))
return NULL;
memset(s, 0, sizeof(SMB2State));
static void *SMTPStateAlloc(void)
{
SMTPState *smtp_state = SCMalloc(sizeof(SMTPState));
- if (smtp_state == NULL)
+ if (unlikely(smtp_state == NULL))
return NULL;
memset(smtp_state, 0, sizeof(SMTPState));
{
/* needed by the mpm */
PatternMatcherQueue *pmq = SCMalloc(sizeof(PatternMatcherQueue));
- if (pmq == NULL) {
- /* we need to exit here, since it is load time */
+ if (unlikely(pmq == NULL)) {
exit(EXIT_FAILURE);
}
PmqSetup(pmq, 0,
static void SMTPSetMpmState(void)
{
smtp_mpm_ctx = SCMalloc(sizeof(MpmCtx));
- if (smtp_mpm_ctx == NULL) {
- /* we need to exit here, since it is load time */
+ if (unlikely(smtp_mpm_ctx == NULL)) {
exit(EXIT_FAILURE);
}
memset(smtp_mpm_ctx, 0, sizeof(MpmCtx));
smtp_mpm_thread_ctx = SCMalloc(sizeof(MpmThreadCtx));
- if (smtp_mpm_thread_ctx == NULL) {
- /* we need to exit here, since it is load time */
+ if (unlikely(smtp_mpm_thread_ctx == NULL)) {
exit(EXIT_FAILURE);
}
memset(smtp_mpm_thread_ctx, 0, sizeof(MpmThreadCtx));
static void *SSHStateAlloc(void)
{
void *s = SCMalloc(sizeof(SshState));
- if (s == NULL)
+ if (unlikely(s == NULL))
return NULL;
memset(s, 0, sizeof(SshState));
void *SSLStateAlloc(void)
{
void *ssl_state = SCMalloc(sizeof(SSLState));
- if (ssl_state == NULL)
+ if (unlikely(ssl_state == NULL))
return NULL;
memset(ssl_state, 0, sizeof(SSLState));
((SSLState*)ssl_state)->client_connp.cert_log_flag = 0;
ConfNode *new;
new = SCCalloc(1, sizeof(*new));
- if (new == NULL) {
+ if (unlikely(new == NULL)) {
return NULL;
}
/* By default we allow an override. */
/* Need to dup the key for tokenization... */
char *tokstr = SCStrdup(key);
- if (tokstr == NULL) {
+ if (unlikely(tokstr == NULL)) {
return NULL;
}
}
else {
char *tokstr = SCStrdup(name);
- if (tokstr == NULL) {
+ if (unlikely(tokstr == NULL)) {
return 0;
}
#if defined(__WIN32) || defined(_WIN32)
size_t path_len = sizeof(char) * (strlen(defaultpath) +
strlen(file) + 2);
path = SCMalloc(path_len);
- if (path == NULL)
+ if (unlikely(path == NULL))
return NULL;
strlcpy(path, defaultpath, path_len);
if (path[strlen(path) - 1] != '/')
strlcat(path, file, path_len);
} else {
path = SCStrdup(file);
- if (path == NULL)
+ if (unlikely(path == NULL))
return NULL;
}
} else {
path = SCStrdup(file);
- if (path == NULL)
+ if (unlikely(path == NULL))
return NULL;
}
return path;
SCCudaPBPacketsBuffer *SCCudaPBAllocSCCudaPBPacketsBuffer(void)
{
SCCudaPBPacketsBuffer *pb = SCMalloc(sizeof(SCCudaPBPacketsBuffer));
- if (pb == NULL) {
+ if (unlikely(pb == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
}
tctx = SCMalloc(sizeof(SCCudaPBThreadCtx));
- if (tctx == NULL) {
+ if (unlikely(tctx == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
SCCudaPBThreadCtx *tctx = NULL;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
DecodeThreadVars dtv;
ThreadVars tv;
SCCudaPBThreadCtx *tctx = NULL;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
DecodeThreadVars dtv;
ThreadVars tv;
0xab, 0xcd };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
AppLayerDecoderEventsModule *new_dev =
SCMalloc(sizeof(AppLayerDecoderEventsModule));
- if (new_dev == NULL)
+ if (unlikely(new_dev == NULL))
return;
new_dev->alproto = alproto;
uint8_t raw_gre[] = { 0x00 ,0x6e ,0x62 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x01, 0x00, 0x00, 0x29, 0x10, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab, 0xab,
0xab };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0xd1, 0x55, 0xe3, 0x93, 0x8b, 0x12, 0x82, 0xaa,
0x00, 0x28, 0x7c, 0xdd };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0xa0, 0x02, 0x16, 0xd0, 0x72, 0x04, 0x00, 0x00,
0x02, 0x04, 0x05, 0x8a, 0x04, 0x02, 0x08, 0x0a };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x23, 0x04, 0x18, 0x00, 0x50, 0xd2, 0x08, 0xc2, 0x48,
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x38};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x08, 0x00, 0x78, 0x47, 0xfc, 0x55, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x80, 0x00, 0x08, 0xb5, 0x99, 0xc3, 0xde, 0x40 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV6Hdr ip6h;
ThreadVars tv;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV6Hdr ip6h;
ThreadVars tv;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV6Hdr ip6h;
ThreadVars tv;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV6Hdr ip6h;
ThreadVars tv;
0x80, 0x00, 0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV6Hdr ip6h;
ThreadVars tv;
0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV6Hdr ip6h;
ThreadVars tv;
0x80, 0x00, 0x08, 0xb5, 0x99, 0xc3, 0xde, 0x40 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV6Hdr ip6h;
ThreadVars tv;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV6Hdr ip6h;
ThreadVars tv;
/* The icmpv6 header is broken in the checksum (so we dont have a complete header) */
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV6Hdr ip6h;
ThreadVars tv;
0x00, 0x00, 0x00, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV6Hdr ip6h;
ThreadVars tv;
0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV6Hdr ip6h;
ThreadVars tv;
0xe5, 0xa5, 0x25, 0xf0, 0x75, 0x23 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV6Hdr ip6h;
ThreadVars tv;
0x00, 0x00, 0x00, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV6Hdr ip6h;
ThreadVars tv;
int DecodeIPV4OptionsNONETest01(void) {
uint8_t raw_opts[] = { };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
uint8_t *data = (uint8_t *)p;
uint16_t i;
IPV4_OPT_EOL, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
uint8_t *data = (uint8_t *)p;
uint16_t i;
IPV4_OPT_NOP, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
uint8_t *data = (uint8_t *)p;
uint16_t i;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
IPV4_OPT_QS, 0x08, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
IPV4_OPT_QS, 0x07, 0x0d, 0x00, 0xbe, 0xef, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x04, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
IPV4_OPT_SID, 0x04, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
IPV4_OPT_SID, 0x05, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
IPV4_OPT_RTRALT, 0x04, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
IPV4_OPT_RTRALT, 0x05, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
int rc;
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
Flow *f = NULL;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x20, 0x20, 0x20, 0x20,
};
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
- return 0;
+ if (unlikely(p1 == NULL))
+ return 0;
Packet *p2 = SCMalloc(SIZE_OF_PACKET);
- if (p2 == NULL) {
- SCFree(p1);
- return 0;
+ if (unlikely(p2 == NULL)) {
+ SCFree(p1);
+ return 0;
}
ThreadVars tv;
DecodeThreadVars dtv;
0xfa, 0x87, 0x00, 0x00,
};
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
- return 0;
+ if (unlikely(p1 == NULL))
+ return 0;
ThreadVars tv;
DecodeThreadVars dtv;
int result = 0;
static int DecodePPPtest01 (void) {
uint8_t raw_ppp[] = { 0xff, 0x03, 0x00, 0x21, 0x45, 0xc0, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x17, 0x6d, 0x0b, 0xba, 0xc3, 0x00, 0x00, 0x00, 0x00,
0x60, 0x02, 0x10, 0x20, 0xdd, 0xe1, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x17, 0x6d, 0x0b, 0xba, 0xc3, 0x00, 0x00, 0x00, 0x00,
0x60, 0x02, 0x10, 0x20, 0xdd, 0xe1, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x17, 0x6d, 0x0b, 0xba, 0xc3, 0x00, 0x00, 0x00, 0x00,
0x60, 0x02, 0x10, 0x20, 0xdd, 0xe1, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
uint8_t raw_pppoe[] = { 0x11, 0x00, 0x00, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x46, 0x47, 0x48, 0x49 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x04, 0x02, 0x08, 0x0a, 0x00, 0xdd, 0x1a, 0x39,
0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x02, 0x04, 0x05, 0xb4, 0x01, 0x01, 0x04, 0x02 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x20, 0x6b, 0x65, 0x79, 0x3b };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x04, 0x02, 0x08, 0x0a, 0x00, 0x62, 0x88, 0x28,
0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV4Hdr ip4h;
ThreadVars tv;
0x04, 0x02, 0x08, 0x0a, 0x00, 0x62, 0x88, 0x28,
0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x0f};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV4Hdr ip4h;
ThreadVars tv;
0x7c, 0x70, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a,
0x00, 0x62, 0x88, 0x9e, 0x00, 0x00, 0x00, 0x00};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV4Hdr ip4h;
ThreadVars tv;
0xf1, 0x59, 0x13, 0xfc, 0xf1, 0x59, 0x1f, 0x64,
0xf1, 0x59, 0x08, 0x94, 0xf1, 0x59, 0x0e, 0x48 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV4Hdr ip4h;
ThreadVars tv;
static int DecodeVLANtest01 (void) {
uint8_t raw_vlan[] = { 0x00, 0x20, 0x08 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x3c, 0x4c, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a,
0x00, 0x04, 0xf0, 0xc8, 0x01, 0x99, 0xa3, 0xf3};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x3c, 0x4c, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a,
0x00, 0x04, 0xf0, 0xc8, 0x01, 0x99, 0xa3, 0xf3};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
Packet *PacketGetFromAlloc(void)
{
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL) {
+ if (unlikely(p == NULL)) {
return NULL;
}
(void) SC_ATOMIC_ADD(defrag_memuse, sizeof(DefragTracker));
DefragTracker *dt = SCMalloc(sizeof(DefragTracker));
- if (dt == NULL)
+ if (unlikely(dt == NULL))
goto error;
memset(dt, 0x00, sizeof(DefragTracker));
exit(EXIT_FAILURE);
}
defragtracker_hash = SCCalloc(defrag_config.hash_size, sizeof(DefragTrackerHashRow));
- if (defragtracker_hash == NULL) {
+ if (unlikely(defragtracker_hash == NULL)) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in DefragTrackerInitConfig. Exiting...");
exit(EXIT_FAILURE);
}
DefragContext *dc;
dc = SCCalloc(1, sizeof(*dc));
- if (dc == NULL)
+ if (unlikely(dc == NULL))
return NULL;
/* Initialize the pool of trackers. */
IPV4Hdr ip4h;
p = SCCalloc(1, sizeof(*p) + default_packet_size);
- if (p == NULL)
+ if (unlikely(p == NULL))
return NULL;
PACKET_INITIALIZE(p);
SET_IPV4_DST_ADDR(p, &p->dst);
pcontent = SCCalloc(1, content_len);
- if (pcontent == NULL)
+ if (unlikely(pcontent == NULL))
return NULL;
memset(pcontent, content, content_len);
PacketCopyDataOffset(p, hlen, pcontent, content_len);
IPV6Hdr ip6h;
p = SCCalloc(1, sizeof(*p) + default_packet_size);
- if (p == NULL)
+ if (unlikely(p == NULL))
return NULL;
PACKET_INITIALIZE(p);
p->ip6eh.ip6fh->ip6fh_offlg = htons((off << 3) | mf);
pcontent = SCCalloc(1, content_len);
- if (pcontent == NULL)
+ if (unlikely(pcontent == NULL))
return NULL;
memset(pcontent, content, content_len);
PacketCopyDataOffset(p, sizeof(IPV6Hdr) + sizeof(IPV6FragHdr), pcontent, content_len);
SigMatch *sm = NULL;
data = SCMalloc(sizeof(DetectAckData));
- if (data == NULL)
+ if (unlikely(data == NULL))
goto error;
sm = SigMatchAlloc();
return NULL;
DetectAppLayerEventData *aled = SCMalloc(sizeof(DetectAppLayerEventData));
- if (aled == NULL)
+ if (unlikely(aled == NULL))
return NULL;
aled->alproto = alproto;
aled->event_id = event_id;
}
fd = SCMalloc(sizeof(DetectAsn1Data));
- if (fd == NULL) {
+ if (unlikely(fd == NULL)) {
exit(EXIT_FAILURE);
}
memset(fd, 0x00, sizeof(DetectAsn1Data));
}
bed = SCMalloc(sizeof(DetectByteExtractData));
- if (bed == NULL)
+ if (unlikely(bed == NULL))
goto error;
memset(bed, 0, sizeof(DetectByteExtractData));
/* Initialize the data */
data = SCMalloc(sizeof(DetectBytejumpData));
- if (data == NULL)
+ if (unlikely(data == NULL))
goto error;
data->base = DETECT_BYTEJUMP_BASE_UNSET;
data->flags = 0;
uint8_t *buf = NULL;
uint16_t buflen = 0;
buf = SCMalloc(4);
- if (buf == NULL) {
+ if (unlikely(buf == NULL)) {
printf("malloc failed\n");
exit(EXIT_FAILURE);
}
/* Initialize the data */
data = SCMalloc(sizeof(DetectBytetestData));
- if (data == NULL)
+ if (unlikely(data == NULL))
goto error;
data->base = DETECT_BYTETEST_BASE_UNSET;
data->flags = 0;
uint8_t *buf = NULL;
uint16_t buflen = 0;
buf = SCMalloc(4);
- if (buf == NULL) {
+ if (unlikely(buf == NULL)) {
printf("malloc failed\n");
exit(EXIT_FAILURE);
}
}
cd = SCMalloc(sizeof(DetectContentData) + len);
- if (cd == NULL) {
+ if (unlikely(cd == NULL)) {
SCFree(str);
exit(EXIT_FAILURE);
}
int result = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
DecodeThreadVars dtv;
if (key[0] == '\"' && key[strlen(key) - 1] == '\"') {
str = SCStrdup(key + 1);
- if (str == NULL) {
+ if (unlikely(str == NULL)) {
goto error;
}
str[strlen(key) - 2] = '\0';
} else {
str = SCStrdup(key);
- if (str == NULL) {
+ if (unlikely(str == NULL)) {
goto error;
}
}
/* strip "'s */
if (depthstr[0] == '\"' && depthstr[strlen(depthstr) - 1] == '\"') {
str = SCStrdup(depthstr + 1);
- if (str == NULL)
+ if (unlikely(str == NULL))
goto error;
str[strlen(depthstr) - 2] = '\0';
dubbed = 1;
int i = 0;
copy_str = SCStrdup(rawstr);
- if (copy_str == NULL) {
+ if (unlikely(copy_str == NULL)) {
goto error;
}
}
df = SCMalloc(sizeof(DetectThresholdData));
- if (df == NULL)
+ if (unlikely(df == NULL))
goto error;
memset(df,0,sizeof(DetectThresholdData));
/* strip "'s */
if (distancestr[0] == '\"' && distancestr[strlen(distancestr) - 1] == '\"') {
str = SCStrdup(distancestr + 1);
- if (str == NULL)
+ if (unlikely(str == NULL))
goto error;
str[strlen(distancestr) - 2] = '\0';
dubbed = 1;
}
dd = SCMalloc(sizeof(DetectDsizeData));
- if (dd == NULL)
+ if (unlikely(dd == NULL))
goto error;
dd->dsize = 0;
dd->dsize2 = 0;
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV6Hdr ip6h;
ThreadVars tv;
DetectAddress *DetectAddressInit(void)
{
DetectAddress *ag = SCMalloc(sizeof(DetectAddress));
- if (ag == NULL)
+ if (unlikely(ag == NULL))
return NULL;
memset(ag, 0, sizeof(DetectAddress));
char *mask = NULL;
int r = 0;
- if (ipdup == NULL)
+ if (unlikely(ipdup == NULL))
return -1;
SCLogDebug("str %s", str);
temp_rule_var_address = rule_var_address;
if ((negate + n_set) % 2) {
temp_rule_var_address = SCMalloc(strlen(rule_var_address) + 3);
- if (temp_rule_var_address == NULL)
+ if (unlikely(temp_rule_var_address == NULL))
goto error;
snprintf(temp_rule_var_address, strlen(rule_var_address) + 3,
"[%s]", rule_var_address);
temp_rule_var_address = rule_var_address;
if ((negate + n_set) % 2) {
temp_rule_var_address = SCMalloc(strlen(rule_var_address) + 3);
- if (temp_rule_var_address == NULL)
+ if (unlikely(temp_rule_var_address == NULL))
goto error;
snprintf(temp_rule_var_address, strlen(rule_var_address) + 3,
"[%s]", rule_var_address);
DetectAddressHead *DetectAddressHeadInit(void)
{
DetectAddressHead *gh = SCMalloc(sizeof(DetectAddressHead));
- if (gh == NULL)
+ if (unlikely(gh == NULL))
return NULL;
memset(gh, 0, sizeof(DetectAddressHead));
}
de = SCMalloc(sizeof(DetectEngineEventData));
- if (de == NULL)
+ if (unlikely(de == NULL))
goto error;
de->event = DEvents[i].code;
*/
int EngineEventTestParse06 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
int ret = 0;
IPOnlyCIDRItem *item = NULL;
item = SCMalloc(sizeof(IPOnlyCIDRItem));
- if (item == NULL)
+ if (unlikely(item == NULL))
SCReturnPtr(NULL, "NULL");
memset(item, 0, sizeof(IPOnlyCIDRItem));
char *mask = NULL;
int r = 0;
- if (ipdup == NULL)
+ if (unlikely(ipdup == NULL))
return -1;
SCLogDebug("str %s", str);
{
SigNumArray *new = SCMalloc(sizeof(SigNumArray));
- if (new == NULL){
+ if (unlikely(new == NULL)) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in SigNumArrayNew. Exiting...");
exit(EXIT_FAILURE);
}
static SigNumArray *SigNumArrayCopy(SigNumArray *orig) {
SigNumArray *new = SCMalloc(sizeof(SigNumArray));
- if (new == NULL) {
+ if (unlikely(new == NULL)) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in SigNumArrayCopy. Exiting...");
exit(EXIT_FAILURE);
}
if ((negate + n_set) % 2) {
temp_rule_var_address = SCMalloc(strlen(rule_var_address) + 3);
- if (temp_rule_var_address == NULL) {
+ if (unlikely(temp_rule_var_address == NULL)) {
goto error;
}
temp_rule_var_address = rule_var_address;
if ((negate + n_set) % 2) {
temp_rule_var_address = SCMalloc(strlen(rule_var_address) + 3);
- if (temp_rule_var_address == NULL) {
+ if (unlikely(temp_rule_var_address == NULL)) {
goto error;
}
snprintf(temp_rule_var_address, strlen(rule_var_address) + 3,
ContentHash *ContentHashAlloc(DetectContentData *ptr) {
ContentHash *ch = SCMalloc(sizeof(ContentHash));
- if (ch == NULL)
+ if (unlikely(ch == NULL))
return NULL;
ch->ptr = ptr;
UricontentHash *UricontentHashAlloc(DetectContentData *ptr) {
UricontentHash *ch = SCMalloc(sizeof(UricontentHash));
- if (ch == NULL)
+ if (unlikely(ch == NULL))
return NULL;
ch->ptr = ptr;
PatIntId id = 0;
e = SCMalloc(sizeof(MpmPatternIdTableElmt));
- if (e == NULL) {
+ if (unlikely(e == NULL)) {
exit(EXIT_FAILURE);
}
*/
DetectPort *DetectPortInit(void) {
DetectPort *dp = SCMalloc(sizeof(DetectPort));
- if (dp == NULL)
+ if (unlikely(dp == NULL))
return NULL;
memset(dp, 0, sizeof(DetectPort));
temp_rule_var_port = rule_var_port;
if (negate == 1 || n_set == 1) {
temp_rule_var_port = SCMalloc(strlen(rule_var_port) + 3);
- if (temp_rule_var_port == NULL)
+ if (unlikely(temp_rule_var_port == NULL))
goto error;
snprintf(temp_rule_var_port, strlen(rule_var_port) + 3,
"[%s]", rule_var_port);
temp_rule_var_port = rule_var_port;
if ((negate + n_set) % 2) {
temp_rule_var_port = SCMalloc(strlen(rule_var_port) + 3);
- if (temp_rule_var_port == NULL)
+ if (unlikely(temp_rule_var_port == NULL))
goto error;
snprintf(temp_rule_var_port, strlen(rule_var_port) + 3,
"[%s]", rule_var_port);
char *port2 = NULL;
DetectPort *dp = NULL;
- if (portdup == NULL) {
+ if (unlikely(portdup == NULL)) {
return NULL;
}
dp = DetectPortInit();
DetectProto *DetectProtoInit(void)
{
DetectProto *dp = SCMalloc(sizeof(DetectProto));
- if (dp == NULL)
+ if (unlikely(dp == NULL))
return NULL;
memset(dp,0,sizeof(DetectProto));
static SigGroupHeadInitData *SigGroupHeadInitDataAlloc(uint32_t size) {
SigGroupHeadInitData *sghid = SCMalloc(sizeof(SigGroupHeadInitData));
- if (sghid == NULL)
+ if (unlikely(sghid == NULL))
return NULL;
memset(sghid, 0x00, sizeof(SigGroupHeadInitData));
static SigGroupHead *SigGroupHeadAlloc(DetectEngineCtx *de_ctx, uint32_t size)
{
SigGroupHead *sgh = SCMalloc(sizeof(SigGroupHead));
- if (sgh == NULL)
+ if (unlikely(sgh == NULL))
return NULL;
memset(sgh, 0, sizeof(SigGroupHead));
SCEnter();
DeStateStore *d = SCMalloc(sizeof(DeStateStore));
- if (d == NULL) {
+ if (unlikely(d == NULL)) {
SCReturnPtr(NULL, "DeStateStore");
}
memset(d, 0x00, sizeof(DeStateStore));
SCEnter();
DetectEngineState *d = SCMalloc(sizeof(DetectEngineState));
- if (d == NULL) {
+ if (unlikely(d == NULL)) {
SCReturnPtr(NULL, "DetectEngineState");
}
memset(d, 0x00, sizeof(DetectEngineState));
static DetectTagDataEntry *DetectTagDataCopy(DetectTagDataEntry *dtd) {
DetectTagDataEntry *tde = SCMalloc(sizeof(DetectTagDataEntry));
- if (tde == NULL) {
+ if (unlikely(tde == NULL)) {
return NULL;
}
memset(tde, 0, sizeof(DetectTagDataEntry));
SCEnter();
DetectThresholdEntry *ste = SCMalloc(sizeof(DetectThresholdEntry));
- if (ste == NULL) {
+ if (unlikely(ste == NULL)) {
SCReturnPtr(NULL, "DetectThresholdEntry");
}
char *insp_recursion_limit = NULL;
de_ctx = SCMalloc(sizeof(DetectEngineCtx));
- if (de_ctx == NULL)
+ if (unlikely(de_ctx == NULL))
goto error;
memset(de_ctx,0,sizeof(DetectEngineCtx));
return TM_ECODE_FAILED;
DetectEngineThreadCtx *det_ctx = SCMalloc(sizeof(DetectEngineThreadCtx));
- if (det_ctx == NULL)
+ if (unlikely(det_ctx == NULL))
return TM_ECODE_FAILED;
memset(det_ctx, 0, sizeof(DetectEngineThreadCtx));
return TM_ECODE_FAILED;
DetectEngineThreadCtx *det_ctx = SCMalloc(sizeof(DetectEngineThreadCtx));
- if (det_ctx == NULL)
+ if (unlikely(det_ctx == NULL))
return TM_ECODE_FAILED;
memset(det_ctx, 0, sizeof(DetectEngineThreadCtx));
BUG_ON(de_ctx == NULL || InitFunc == NULL || FreeFunc == NULL || data == NULL);
DetectEngineThreadKeywordCtxItem *item = SCMalloc(sizeof(DetectEngineThreadKeywordCtxItem));
- if (item == NULL)
+ if (unlikely(item == NULL))
return -1;
memset(item, 0x00, sizeof(DetectEngineThreadKeywordCtxItem));
}
SCFPSupportSMList *new_smlist_fp = SCMalloc(sizeof(SCFPSupportSMList));
- if (new_smlist_fp == NULL) {
+ if (unlikely(new_smlist_fp == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
/* We have a correct filename option */
fileext = SCMalloc(sizeof(DetectFileextData));
- if (fileext == NULL)
+ if (unlikely(fileext == NULL))
goto error;
memset(fileext, 0x00, sizeof(DetectFileextData));
/* We have a correct filemagic option */
filemagic = SCMalloc(sizeof(DetectFilemagicData));
- if (filemagic == NULL)
+ if (unlikely(filemagic == NULL))
goto error;
memset(filemagic, 0x00, sizeof(DetectFilemagicData));
/* We have a correct filemd5 option */
filemd5 = SCMalloc(sizeof(DetectFileMd5Data));
- if (filemd5 == NULL)
+ if (unlikely(filemd5 == NULL))
goto error;
memset(filemd5, 0x00, sizeof(DetectFileMd5Data));
/* We have a correct filename option */
filename = SCMalloc(sizeof(DetectFilenameData));
- if (filename == NULL)
+ if (unlikely(filename == NULL))
goto error;
memset(filename, 0x00, sizeof(DetectFilenameData));
}
fsd = SCMalloc(sizeof (DetectFilesizeData));
- if (fsd == NULL)
- goto error;
+ if (unlikely(fsd == NULL))
+ goto error;
memset(fsd, 0, sizeof(DetectFilesizeData));
if (arg1[0] == '<')
}
fd = SCMalloc(sizeof(DetectFilestoreData));
- if (fd == NULL)
+ if (unlikely(fd == NULL))
goto error;
memset(fd, 0x00, sizeof(DetectFilestoreData));
}
de = SCMalloc(sizeof(DetectFlagsData));
- if (de == NULL)
+ if (unlikely(de == NULL))
goto error;
memset(de,0,sizeof(DetectFlagsData));
*/
static int FlagsTestParse03 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
int ret = 0;
*/
static int FlagsTestParse04 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
int ret = 0;
*/
static int FlagsTestParse05 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
int ret = 0;
*/
static int FlagsTestParse06 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
int ret = 0;
*/
static int FlagsTestParse07 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
int ret = 0;
*/
static int FlagsTestParse08 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
int ret = 0;
*/
static int FlagsTestParse09 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
int ret = 0;
*/
static int FlagsTestParse10 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
int ret = 0;
*/
static int FlagsTestParse11 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
int ret = 0;
*/
static int FlagsTestParse12 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
int ret = 0;
static int FlagsTestParse15(void)
{
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
int ret = 0;
static int FlagsTestParse16(void)
{
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
int ret = 0;
static int FlagsTestParse17(void)
{
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
int ret = 0;
}
fd = SCMalloc(sizeof(DetectFlowData));
- if (fd == NULL)
+ if (unlikely(fd == NULL))
goto error;
fd->flags = 0;
fd->match_cnt = 0;
}
cd = SCMalloc(sizeof(DetectFlowbitsData));
- if (cd == NULL)
+ if (unlikely(cd == NULL))
goto error;
cd->idx = VariableNameGetIdx(de_ctx, fb_name, DETECT_FLOWBITS);
"\r\n";
uint16_t buflen = strlen((char *)buf);
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
ThreadVars th_v;
"\r\n";
uint16_t buflen = strlen((char *)buf);
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
ThreadVars th_v;
"\r\n";
uint16_t buflen = strlen((char *)buf);
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
ThreadVars th_v;
"\r\n";
uint16_t buflen = strlen((char *)buf);
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
ThreadVars th_v;
"\r\n";
uint16_t buflen = strlen((char *)buf);
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
ThreadVars th_v;
"\r\n";
uint16_t buflen = strlen((char *)buf);
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
ThreadVars th_v;
"\r\n";
uint16_t buflen = strlen((char *)buf);
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
ThreadVars th_v;
"\r\n";
uint16_t buflen = strlen((char *)buf);
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
ThreadVars th_v;
}
sfd = SCMalloc(sizeof(DetectFlowintData));
- if (sfd == NULL)
+ if (unlikely(sfd == NULL))
goto error;
/* If we need another arg, check it out(isset doesn't need another arg) */
/* get the target value to operate with
*(it should be a value or another var) */
str = SCStrdup(varval);
- if (str == NULL) {
+ if (unlikely(str == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "malloc from strdup failed");
goto error;
}
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
DecodeThreadVars dtv;
ThreadVars th_v;
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
DecodeThreadVars dtv;
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
DecodeThreadVars dtv;
if (varcontent[0] == '\"' && varcontent[strlen(varcontent)-1] == '\"') {
str = SCStrdup(varcontent+1);
- if (str == NULL) {
+ if (unlikely(str == NULL)) {
return -1;
}
str[strlen(varcontent)-2] = '\0';
}
cd = SCMalloc(sizeof(DetectFlowvarData));
- if (cd == NULL)
+ if (unlikely(cd == NULL))
goto error;
char converted = 0;
}
de = SCMalloc(sizeof(DetectFragBitsData));
- if (de == NULL)
+ if (unlikely(de == NULL))
goto error;
memset(de,0,sizeof(DetectFragBitsData));
0x00 ,0x0e ,0x10 ,0x00 ,0x04 ,0x81 ,0x6f ,0x0b,
0x51};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x00 ,0x0e ,0x10 ,0x00 ,0x04 ,0x81 ,0x6f ,0x0b,
0x51};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
}
fragoff = SCMalloc(sizeof(DetectFragOffsetData));
- if (fragoff == NULL)
+ if (unlikely(fragoff == NULL))
goto error;
fragoff->frag_off = 0;
int DetectFragOffsetMatchTest01 (void) {
int result = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
DecodeThreadVars dtv;
TcpSession ssn;
Flow f;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
ThreadVars th_v;
}
iid = SCMalloc(sizeof(DetectIcmpIdData));
- if (iid == NULL)
+ if (unlikely(iid == NULL))
goto error;
iid->id = 0;
0x00, 0x14, 0x00, 0x00 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
DecodeThreadVars dtv;
}
iseq = SCMalloc(sizeof(DetectIcmpSeqData));
- if (iseq == NULL)
+ if (unlikely(iseq == NULL))
goto error;
iseq->seq = 0;
}
icd = SCMalloc(sizeof(DetectICodeData));
- if (icd == NULL)
+ if (unlikely(icd == NULL))
goto error;
icd->code1 = 0;
icd->code2 = 0;
/* We have a correct id option */
id_d = SCMalloc(sizeof(DetectIdData));
- if (id_d == NULL)
+ if (unlikely(id_d == NULL))
goto error;
orig = SCStrdup((char*)str_ptr);
- if (orig == NULL) {
+ if (unlikely(orig == NULL)) {
goto error;
}
tmp_str=orig;
goto error;
de = SCMalloc(sizeof(DetectIpOptsData));
- if (de == NULL)
+ if (unlikely(de == NULL))
goto error;
de->ipopt = DIpOpts[i].code;
*/
int IpOptsTestParse03 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
int ret = 0;
*/
int IpOptsTestParse04 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
int ret = 0;
/* Initialize the data */
data = SCMalloc(sizeof(DetectIPProtoData));
- if (data == NULL)
+ if (unlikely(data == NULL))
goto error;
data->op = DETECT_IPPROTO_OP_EQ;
data->proto = 0;
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
}
idad = SCMalloc(sizeof(DetectIsdataatData));
- if (idad == NULL)
+ if (unlikely(idad == NULL))
goto error;
idad->flags = 0;
}
itd = SCMalloc(sizeof(DetectITypeData));
- if (itd == NULL)
+ if (unlikely(itd == NULL))
goto error;
itd->type1 = 0;
itd->type2 = 0;
/* strip "'s */
if (optstr[0] == '\"' && optstr[strlen(optstr) - 1] == '\"') {
str = SCStrdup(optstr + 1);
- if (str == NULL)
+ if (unlikely(str == NULL))
goto error;
str[strlen(optstr) - 2] = '\0';
dubbed = 1;
static int DetectL3protoTestSig1(void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
ThreadVars th_v;
static int DetectL3protoTestSig2(void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
ThreadVars th_v;
static int DetectL3protoTestSig3(void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
ThreadVars th_v;
BUG_ON(luajit == NULL);
DetectLuajitThreadData *t = SCMalloc(sizeof(DetectLuajitThreadData));
- if (t == NULL) {
+ if (unlikely(t == NULL)) {
SCLogError(SC_ERR_LUAJIT_ERROR, "couldn't alloc ctx memory");
return NULL;
}
/* We have a correct luajit option */
luajit = SCMalloc(sizeof(DetectLuajitData));
- if (luajit == NULL)
+ if (unlikely(luajit == NULL))
goto error;
memset(luajit, 0x00, sizeof(DetectLuajitData));
if (ptr == NULL) {
data = SCMalloc(sizeof(DetectMarkData));
- if (data == NULL) {
+ if (unlikely(data == NULL)) {
return NULL;
}
data->mark = mark;
SCFree(ptr);
data = SCMalloc(sizeof(DetectMarkData));
- if (data == NULL) {
+ if (unlikely(data == NULL)) {
return NULL;
}
data->mark = mark;
/* strip "'s */
if (msgstr[0] == '\"' && msgstr[strlen(msgstr)-1] == '\"') {
str = SCStrdup(msgstr+1);
- if (str == NULL)
+ if (unlikely(str == NULL))
goto error;
str[strlen(msgstr)-2] = '\0';
} else if (msgstr[1] == '\"' && msgstr[strlen(msgstr)-1] == '\"') {
/* XXX do this parsing in a better way */
str = SCStrdup(msgstr+2);
- if (str == NULL)
+ if (unlikely(str == NULL))
goto error;
str[strlen(msgstr)-3] = '\0';
//printf("DetectMsgSetup: format hack applied: \'%s\'\n", str);
/* strip "'s */
if (offsetstr[0] == '\"' && offsetstr[strlen(offsetstr)-1] == '\"') {
str = SCStrdup(offsetstr+1);
- if (str == NULL)
+ if (unlikely(str == NULL))
goto error;
str[strlen(offsetstr)-2] = '\0';
dubbed = 1;
SigMatch *SigMatchAlloc(void) {
SigMatch *sm = SCMalloc(sizeof(SigMatch));
- if (sm == NULL)
+ if (unlikely(sm == NULL))
return NULL;
memset(sm, 0, sizeof(SigMatch));
char *optname = NULL, *optvalue = NULL, *optmore = NULL;
const char **arr = SCCalloc(OPTION_PARTS+1, sizeof(char *));
- if (arr == NULL)
- return -1;
+ if (unlikely(arr == NULL))
+ return -1;
ret = pcre_exec(option_pcre, option_pcre_extra, optstr, strlen(optstr), 0, 0, ov, MAX_SUBSTRINGS);
/* if successful, we either have:
int ret = 0, i = 0;
const char **arr = SCCalloc(CONFIG_PARTS + 1, sizeof(char *));
- if (arr == NULL)
- return -1;
+ if (unlikely(arr == NULL))
+ return -1;
ret = pcre_exec(config_pcre, config_pcre_extra, sigstr, strlen(sigstr), 0, 0, ov, MAX_SUBSTRINGS);
if (ret != 8 && ret != 9) {
Signature *SigAlloc (void) {
Signature *sig = SCMalloc(sizeof(Signature));
- if (sig == NULL)
+ if (unlikely(sig == NULL))
return NULL;
memset(sig, 0, sizeof(Signature));
/* used for making a duplicate_sig_hash_table entry */
sw = SCMalloc(sizeof(SigDuplWrapper));
- if (sw == NULL) {
+ if (unlikely(sw == NULL)) {
exit(EXIT_FAILURE);
}
memset(sw, 0, sizeof(SigDuplWrapper));
}
content = SCMalloc(len);
- if (content == NULL) {
+ if (unlikely(content == NULL)) {
exit(EXIT_FAILURE);
}
0x76,0x65,0x0d,0x0a,0x0d,0x0a }; /* end rawpkt1_ether */
p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
DecodeThreadVars dtv;
ThreadVars th_v;
//printf("ret %" PRId32 " re \'%s\', op \'%s\'\n", ret, re, op);
pd = SCMalloc(sizeof(DetectPcreData));
- if (pd == NULL)
+ if (unlikely(pd == NULL))
goto error;
memset(pd, 0, sizeof(DetectPcreData));
if (varcontent[0] == '\"' && varcontent[strlen(varcontent)-1] == '\"') {
str = SCStrdup(varcontent+1);
- if (str == NULL) {
+ if (unlikely(str == NULL)) {
return -1;
}
str[strlen(varcontent)-2] = '\0';
}
cd = SCMalloc(sizeof(DetectPktvarData));
- if (cd == NULL)
+ if (unlikely(cd == NULL))
goto error;
char converted = 0;
}
ref = SCMalloc(sizeof(DetectReference));
- if (ref == NULL) {
+ if (unlikely(ref == NULL)) {
goto error;
}
memset(ref, 0, sizeof(DetectReference));
SCLogDebug("replace: Adding match");
newlist = SCMalloc(sizeof(DetectReplaceList));
- if (newlist == NULL)
+ if (unlikely(newlist == NULL))
return NULL;
newlist->found = found;
newlist->cd = cd;
Packet *p = NULL;
p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
DecodeThreadVars dtv;
/* strip "'s */
if (rawstr[0] == '\"' && rawstr[strlen(rawstr)-1] == '\"') {
str = SCStrdup(rawstr+1);
- if (str == NULL)
+ if (unlikely(str == NULL))
return -1;
str[strlen(rawstr)-2] = '\0';
}
rd = SCMalloc(sizeof(DetectRpcData));
- if (rd == NULL)
+ if (unlikely(rd == NULL))
goto error;
rd->flags = 0;
rd->program = 0;
SigMatch *sm = NULL;
data = SCMalloc(sizeof(DetectSeqData));
- if (data == NULL)
+ if (unlikely(data == NULL))
goto error;
sm = SigMatchAlloc();
/* strip "'s */
if (sidstr[0] == '\"' && sidstr[strlen(sidstr)-1] == '\"') {
str = SCStrdup(sidstr+1);
- if (str == NULL)
+ if (unlikely(str == NULL))
return -1;
str[strlen(sidstr)-2] = '\0';
/* We have a correct id option */
ssh = SCMalloc(sizeof(DetectSshVersionData));
- if (ssh == NULL)
+ if (unlikely(ssh == NULL))
goto error;
memset(ssh, 0x00, sizeof(DetectSshVersionData));
/* We have a correct id option */
ssh = SCMalloc(sizeof(DetectSshSoftwareVersionData));
- if (ssh == NULL)
+ if (unlikely(ssh == NULL))
goto error;
ssh->software_ver = (uint8_t *)SCStrdup((char*)str_ptr);
/* We have a correct ssl_version options */
ssl = SCCalloc(1, sizeof (DetectSslVersionData));
- if (ssl == NULL)
+ if (unlikely(ssl == NULL))
goto error;
int i;
}
orig = SCStrdup((char*) str_ptr[i]);
- if (orig == NULL) {
+ if (unlikely(orig == NULL)) {
goto error;
}
tmp_str = orig;
value = (char *)str_ptr;
sd = SCMalloc(sizeof(DetectStreamSizeData));
- if (sd == NULL)
- goto error;
+ if (unlikely(sd == NULL))
+ goto error;
sd->ssize = 0;
sd->flags = 0;
ThreadVars tv;
DetectEngineThreadCtx dtx;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Signature s;
SigMatch sm;
ThreadVars tv;
DetectEngineThreadCtx dtx;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Signature s;
SigMatch sm;
}
DetectTagData *real_td = SCMalloc(sizeof(DetectTagData));
- if (real_td == NULL) {
+ if (unlikely(real_td == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
goto error;
}
int i = 0;
copy_str = SCStrdup(rawstr);
- if (copy_str == NULL) {
+ if (unlikely(copy_str == NULL)) {
goto error;
}
}
de = SCMalloc(sizeof(DetectThresholdData));
- if (de == NULL)
+ if (unlikely(de == NULL))
goto error;
memset(de,0,sizeof(DetectThresholdData));
/* We have a correct id option */
tls = SCMalloc(sizeof(DetectTlsVersionData));
- if (tls == NULL)
+ if (unlikely(tls == NULL))
goto error;
orig = SCStrdup((char*)str_ptr);
- if (orig == NULL) {
+ if (unlikely(orig == NULL)) {
goto error;
}
tmp_str=orig;
/* We have a correct id option */
tls = SCMalloc(sizeof(DetectTlsData));
- if (tls == NULL)
+ if (unlikely(tls == NULL))
goto error;
tls->subject = NULL;
tls->flags = flag;
orig = SCStrdup((char*)str_ptr);
- if (orig == NULL) {
+ if (unlikely(orig == NULL)) {
goto error;
}
tmp_str=orig;
/* We have a correct id option */
tls = SCMalloc(sizeof(DetectTlsData));
- if (tls == NULL)
+ if (unlikely(tls == NULL))
goto error;
tls->issuerdn = NULL;
tls->flags = flag;
orig = SCStrdup((char*)str_ptr);
- if (orig == NULL) {
+ if (unlikely(orig == NULL)) {
goto error;
}
tmp_str=orig;
/* We have a correct id option */
tls = SCMalloc(sizeof(DetectTlsData));
- if (tls == NULL)
+ if (unlikely(tls == NULL))
goto error;
tls->fingerprint = NULL;
tls->flags = flag;
orig = SCStrdup((char*)str_ptr);
- if (orig == NULL) {
+ if (unlikely(orig == NULL)) {
goto error;
}
tmp_str=orig;
}
tosd = SCMalloc(sizeof(DetectTosData));
- if (tosd == NULL)
+ if (unlikely(tosd == NULL))
goto error;
tosd->tos = (uint8_t)tos;
tosd->negated = negated;
}
ttld = SCMalloc(sizeof (DetectTtlData));
- if (ttld == NULL)
- goto error;
+ if (unlikely(ttld == NULL))
+ goto error;
ttld->ttl1 = 0;
ttld->ttl2 = 0;
static int DetectTtlTestSig1(void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Signature *s = NULL;
ThreadVars th_v;
return;
}
char *tmpstr = SCMalloc(sizeof(char) * cd->content_len + 1);
- if (tmpstr == NULL)
+ if (unlikely(tmpstr == NULL))
return;
if (tmpstr != NULL) {
}
cd = SCMalloc(sizeof(DetectContentData) + len);
- if (cd == NULL) {
+ if (unlikely(cd == NULL)) {
SCFree(str);
exit(EXIT_FAILURE);
}
}
urilend = SCMalloc(sizeof (DetectUrilenData));
- if (urilend == NULL)
- goto error;
+ if (unlikely(urilend == NULL))
+ goto error;
memset(urilend, 0, sizeof(DetectUrilenData));
if (arg1[0] == '<')
}
wd = SCMalloc(sizeof(DetectWindowData));
- if (wd == NULL)
+ if (unlikely(wd == NULL))
goto error;
if (ret > 1) {
/* strip "'s */
if (withinstr[0] == '\"' && withinstr[strlen(withinstr)-1] == '\"') {
str = SCStrdup(withinstr+1);
- if (str == NULL)
+ if (unlikely(str == NULL))
goto error;
str[strlen(withinstr)-2] = '\0';
dubbed = 1;
size_t path_len = sizeof(char) * (strlen(defaultpath) +
strlen(sig_file) + 2);
path = SCMalloc(path_len);
- if (path == NULL)
+ if (unlikely(path == NULL))
return NULL;
strlcpy(path, defaultpath, path_len);
#if defined OS_WIN32 || defined __CYGWIN__
strlcat(path, sig_file, path_len);
} else {
path = SCStrdup(sig_file);
- if (path == NULL)
+ if (unlikely(path == NULL))
return NULL;
}
} else {
path = SCStrdup(sig_file);
- if (path == NULL)
+ if (unlikely(path == NULL))
return NULL;
}
return path;
uint16_t patlen = fp_cd->content_len;
uint8_t *pat = SCMalloc(fp_cd->content_len + 1);
- if (pat == NULL) {
+ if (unlikely(pat == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
SCFree(pat);
patlen = fp_cd->fp_chop_len;
pat = SCMalloc(fp_cd->fp_chop_len + 1);
- if (pat == NULL) {
+ if (unlikely(pat == NULL)) {
exit(EXIT_FAILURE);
}
memcpy(pat, fp_cd->content + fp_cd->fp_chop_offset, fp_cd->fp_chop_len);
"CONNECT 213.92.8.7:31204 HTTP/1.1";
uint16_t buflen = strlen((char *)buf);
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars th_v;
DetectEngineThreadCtx *det_ctx;
"220 (vsFTPd 2.0.5)\r\n";
uint16_t buflen = strlen((char *)buf);
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars th_v;
DetectEngineThreadCtx *det_ctx;
"220 (vsFTPd 2.0.5)\r\n";
uint16_t buflen = strlen((char *)buf);
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars th_v;
DetectEngineThreadCtx *det_ctx;
"220 (vsFTPd 2.0.5)\r\n";
uint16_t buflen = strlen((char *)buf);
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars th_v;
DetectEngineThreadCtx *det_ctx;
0xc0, 0xa8, 0x01, 0x06};
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
+ if (unlikely(p1 == NULL))
return 0;
Packet *p2 = SCMalloc(SIZE_OF_PACKET);
- if (p2 == NULL) {
+ if (unlikely(p2 == NULL)) {
SCFree(p1);
return 0;
}
0xc0, 0xa8, 0x01, 0x06};
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
+ if (unlikely(p1 == NULL))
return 0;
Packet *p2 = SCMalloc(SIZE_OF_PACKET);
- if (p2 == NULL) {
+ if (unlikely(p2 == NULL)) {
SCFree(p1);
return 0;
}
0x01, 0x71, 0x74, 0xde, 0x01, 0x03, 0x03, 0x03};
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
+ if (unlikely(p1 == NULL))
return 0;
Packet *p2 = SCMalloc(SIZE_OF_PACKET);
- if (p2 == NULL) {
+ if (unlikely(p2 == NULL)) {
SCFree(p1);
return 0;
}
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
+ if (unlikely(p1 == NULL))
return 0;
Packet *p2 = SCMalloc(SIZE_OF_PACKET);
- if (p2 == NULL) {
+ if (unlikely(p2 == NULL)) {
SCFree(p1);
return 0;
}
0x00, 0x01, 0x69, 0x28};
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
+ if (unlikely(p1 == NULL))
return 0;
Packet *p2 = SCMalloc(SIZE_OF_PACKET);
- if (p2 == NULL) {
+ if (unlikely(p2 == NULL)) {
SCFree(p1);
return 0;
}
0x00, 0x01, 0x69, 0x28};
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
+ if (unlikely(p1 == NULL))
return 0;
Packet *p2 = SCMalloc(SIZE_OF_PACKET);
- if (p2 == NULL) {
+ if (unlikely(p2 == NULL)) {
SCFree(p1);
return 0;
}
0x67, 0x6c, 0x65, 0xc0, 0x27};
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
+ if (unlikely(p1 == NULL))
return 0;
Packet *p2 = SCMalloc(SIZE_OF_PACKET);
- if (p2 == NULL) {
+ if (unlikely(p2 == NULL)) {
SCFree(p1);
return 0;
}
0x67, 0x6c, 0x65, 0xc0, 0x27};
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
+ if (unlikely(p1 == NULL))
return 0;
Packet *p2 = SCMalloc(SIZE_OF_PACKET);
- if (p2 == NULL) {
+ if (unlikely(p2 == NULL)) {
SCFree(p1);
return 0;
}
0x09, 0x01};
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
+ if (unlikely(p1 == NULL))
return 0;
Packet *p2 = SCMalloc(SIZE_OF_PACKET);
- if (p2 == NULL) {
+ if (unlikely(p2 == NULL)) {
SCFree(p1);
return 0;
}
0x09, 0x01};
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
+ if (unlikely(p1 == NULL))
return 0;
Packet *p2 = SCMalloc(SIZE_OF_PACKET);
- if (p2 == NULL) {
+ if (unlikely(p2 == NULL)) {
SCFree(p1);
return 0;
}
0x34, 0x35, 0x36, 0x38};
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
+ if (unlikely(p1 == NULL))
return 0;
Packet *p2 = SCMalloc(SIZE_OF_PACKET);
- if (p2 == NULL) {
+ if (unlikely(p2 == NULL)) {
SCFree(p1);
return 0;
}
0x34, 0x35, 0x36, 0x38};
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
+ if (unlikely(p1 == NULL))
return 0;
Packet *p2 = SCMalloc(SIZE_OF_PACKET);
- if (p2 == NULL) {
+ if (unlikely(p2 == NULL)) {
SCFree(p1);
return 0;
}
0x08, 0x01};
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
+ if (unlikely(p1 == NULL))
return 0;
Packet *p2 = SCMalloc(SIZE_OF_PACKET);
- if (p2 == NULL) {
+ if (unlikely(p2 == NULL)) {
SCFree(p1);
return 0;
}
0x08, 0x01};
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
+ if (unlikely(p1 == NULL))
return 0;
Packet *p2 = SCMalloc(SIZE_OF_PACKET);
- if (p2 == NULL) {
+ if (unlikely(p2 == NULL)) {
SCFree(p1);
return 0;
}
int SigTest38Real(int mpm_type)
{
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
+ if (unlikely(p1 == NULL))
return 0;
ThreadVars th_v;
DetectEngineThreadCtx *det_ctx = NULL;
int SigTest39Real(int mpm_type)
{
Packet *p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
+ if (unlikely(p1 == NULL))
return 0;
ThreadVars th_v;
DetectEngineThreadCtx *det_ctx = NULL;
,0x3e,0x3c,0x2f,0x48,0x54,0x4d,0x4c,0x3e,0x0d,0x0a };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
DecodeThreadVars dtv;
,0x3e,0x3c,0x2f,0x48,0x54,0x4d,0x4c,0x3e,0x0d,0x0a };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
DecodeThreadVars dtv;
uint16_t buflen = strlen((char *)buf);
Packet *p = SCMalloc(SIZE_OF_PACKET);
TCPHdr tcphdr;
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars th_v;
DetectEngineThreadCtx *det_ctx;
"220 (vsFTPd 2.0.5)\r\n";
uint16_t buflen = strlen((char *)buf);
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars th_v;
DetectEngineThreadCtx *det_ctx;
"\r\n\r\n";
uint16_t buflen = strlen((char *)buf);
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars th_v;
DetectEngineThreadCtx *det_ctx;
ThreadVars th_v;
int result = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
DetectEngineThreadCtx *det_ctx;
ThreadVars th_v;
int result = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
DetectEngineThreadCtx *det_ctx;
ThreadVars th_v;
int result = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
DetectEngineThreadCtx *det_ctx;
/* packet 1 */
p1 = SCMalloc(SIZE_OF_PACKET);
- if (p1 == NULL)
+ if (unlikely(p1 == NULL))
return 0;
memset(p1, 0, SIZE_OF_PACKET);
p1->pkt = (uint8_t *)(p1 + 1);
/* packet 2 */
p2 = SCMalloc(SIZE_OF_PACKET);
- if (p2 == NULL)
+ if (unlikely(p2 == NULL))
return 0;
memset(p2, 0, SIZE_OF_PACKET);
p2->pkt = (uint8_t *)(p2 + 1);
/* packet 3 */
p3 = SCMalloc(SIZE_OF_PACKET);
- if (p3 == NULL)
+ if (unlikely(p3 == NULL))
return 0;
memset(p3, 0, SIZE_OF_PACKET);
p3->pkt = (uint8_t *)(p3 + 1);
/* packet 4 */
p4 = SCMalloc(SIZE_OF_PACKET);
- if (p4 == NULL)
+ if (unlikely(p4 == NULL))
return 0;
memset(p4, 0, SIZE_OF_PACKET);
p4->pkt = (uint8_t *)(p4 + 1);
FlowAlertSid *fb = FlowAlertSidGet(f, sid);
if (fb == NULL) {
fb = SCMalloc(sizeof(FlowAlertSid));
- if (fb == NULL)
+ if (unlikely(fb == NULL))
return;
fb->type = DETECT_FLOWALERTSID;
FlowBit *fb = FlowBitGet(f, idx);
if (fb == NULL) {
fb = SCMalloc(sizeof(FlowBit));
- if (fb == NULL)
+ if (unlikely(fb == NULL))
return;
fb->type = DETECT_FLOWBITS;
(void) SC_ATOMIC_ADD(flow_memuse, sizeof(Flow));
f = SCMalloc(sizeof(Flow));
- if (f == NULL) {
- (void) SC_ATOMIC_SUB(flow_memuse, sizeof(Flow));
+ if (unlikely(f == NULL)) {
+ (void)SC_ATOMIC_SUB(flow_memuse, sizeof(Flow));
return NULL;
}
FlowVar *fv = FlowVarGet(f, idx);
if (fv == NULL) {
fv = SCMalloc(sizeof(FlowVar));
- if (fv == NULL)
+ if (unlikely(fv == NULL))
goto out;
fv->type = DETECT_FLOWVAR;
FlowVar *fv = FlowVarGet(f, idx);
if (fv == NULL) {
fv = SCMalloc(sizeof(FlowVar));
- if (fv == NULL)
+ if (unlikely(fv == NULL))
goto out;
fv->type = DETECT_FLOWVAR;
exit(EXIT_FAILURE);
}
flow_hash = SCCalloc(flow_config.hash_size, sizeof(FlowBucket));
- if (flow_hash == NULL) {
+ if (unlikely(flow_hash == NULL)) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in FlowInitConfig. Exiting...");
exit(EXIT_FAILURE);
}
(void) SC_ATOMIC_ADD(host_memuse, sizeof(Host));
Host *h = SCMalloc(sizeof(Host));
- if (h == NULL)
+ if (unlikely(h == NULL))
goto error;
memset(h, 0x00, sizeof(Host));
exit(EXIT_FAILURE);
}
host_hash = SCCalloc(host_config.hash_size, sizeof(HostHashRow));
- if (host_hash == NULL) {
+ if (unlikely(host_hash == NULL)) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in HostInitConfig. Exiting...");
exit(EXIT_FAILURE);
}
}
LogDropLogThread *dlt = SCMalloc(sizeof(LogDropLogThread));
- if (dlt == NULL)
+ if (unlikely(dlt == NULL))
return TM_ECODE_FAILED;
memset(dlt, 0, sizeof(LogDropLogThread));
}
OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
- if (output_ctx == NULL) {
+ if (unlikely(output_ctx == NULL)) {
LogFileFreeCtx(logfile_ctx);
return NULL;
}
TmEcode LogFileLogThreadInit(ThreadVars *t, void *initdata, void **data)
{
LogFileLogThread *aft = SCMalloc(sizeof(LogFileLogThread));
- if (aft == NULL)
+ if (unlikely(aft == NULL))
return TM_ECODE_FAILED;
memset(aft, 0, sizeof(LogFileLogThread));
}
OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
- if (output_ctx == NULL)
+ if (unlikely(output_ctx == NULL))
return NULL;
output_ctx->data = logfile_ctx;
TmEcode LogFilestoreLogThreadInit(ThreadVars *t, void *initdata, void **data)
{
LogFilestoreLogThread *aft = SCMalloc(sizeof(LogFilestoreLogThread));
- if (aft == NULL)
+ if (unlikely(aft == NULL))
return TM_ECODE_FAILED;
memset(aft, 0, sizeof(LogFilestoreLogThread));
}
OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
- if (output_ctx == NULL)
+ if (unlikely(output_ctx == NULL))
return NULL;
output_ctx->data = NULL;
TmEcode LogHttpLogThreadInit(ThreadVars *t, void *initdata, void **data)
{
LogHttpLogThread *aft = SCMalloc(sizeof(LogHttpLogThread));
- if (aft == NULL)
+ if (unlikely(aft == NULL))
return TM_ECODE_FAILED;
memset(aft, 0, sizeof(LogHttpLogThread));
}
LogHttpFileCtx *httplog_ctx = SCMalloc(sizeof(LogHttpFileCtx));
- if (httplog_ctx == NULL) {
+ if (unlikely(httplog_ctx == NULL)) {
LogFileFreeCtx(file_ctx);
return NULL;
}
}
OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
- if (output_ctx == NULL) {
- for (n = 0; n < httplog_ctx->cf_n; n++) {
+ if (unlikely(output_ctx == NULL)) {
+ for (n = 0;n < httplog_ctx->cf_n;n++) {
SCFree(httplog_ctx->cf_nodes[n]);
}
LogFileFreeCtx(file_ctx);
OutputCtx *PcapLogInitCtx(ConfNode *conf)
{
PcapLogData *pl = SCMalloc(sizeof(PcapLogData));
- if (pl == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "Failed to allocate Memory for PcapLogData");
+ if (unlikely(pl == NULL)) {
+ SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate Memory for PcapLogData");
exit(EXIT_FAILURE);
}
memset(pl, 0, sizeof(PcapLogData));
/* create the output ctx and send it back */
OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
- if (output_ctx == NULL) {
+ if (unlikely(output_ctx == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for OutputCtx.");
exit(EXIT_FAILURE);
}
/* Place to store the name of our PCAP file */
PcapFileName *pf = SCMalloc(sizeof(PcapFileName));
- if (pf == NULL) {
+ if (unlikely(pf == NULL)) {
return -1;
}
memset(pf, 0, sizeof(PcapFileName));
TmEcode LogTlsLogThreadInit(ThreadVars *t, void *initdata, void **data)
{
LogTlsLogThread *aft = SCMalloc(sizeof(LogTlsLogThread));
- if (aft == NULL)
+ if (unlikely(aft == NULL))
return TM_ECODE_FAILED;
memset(aft, 0, sizeof(LogTlsLogThread));
}
LogTlsFileCtx *tlslog_ctx = SCCalloc(1, sizeof(LogTlsFileCtx));
- if (tlslog_ctx == NULL)
+ if (unlikely(tlslog_ctx == NULL))
goto filectx_error;
tlslog_ctx->file_ctx = file_ctx;
}
OutputCtx *output_ctx = SCCalloc(1, sizeof(OutputCtx));
- if (output_ctx == NULL)
+ if (unlikely(output_ctx == NULL))
goto tlslog_error;
output_ctx->data = tlslog_ctx;
output_ctx->DeInit = LogTlsLogDeInitCtx;
OutputCtx *(*InitFunc)(ConfNode *))
{
OutputModule *module = SCCalloc(1, sizeof(*module));
- if (module == NULL) {
+ if (unlikely(module == NULL)) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in OutputRegisterModule. Exiting...");
exit(EXIT_FAILURE);
}
PktVar *pv = PktVarGet(p, name);
if (pv == NULL) {
pv = SCMalloc(sizeof(PktVar));
- if (pv == NULL)
+ if (unlikely(pv == NULL))
return;
pv->name = name;
char *bpf_filter = NULL;
char *out_iface = NULL;
- if (aconf == NULL) {
+ if (unlikely(aconf == NULL)) {
return NULL;
}
SCLogDebug("tname %s, qname %s", tname, qname);
char *thread_name = SCStrdup(tname);
- if (thread_name == NULL) {
+ if (unlikely(thread_name == NULL)) {
printf("ERROR: Can't allocate thread name\n");
exit(EXIT_FAILURE);
}
}
char *thread_group_name = SCStrdup("Detect");
- if (thread_group_name == NULL) {
+ if (unlikely(thread_group_name == NULL)) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
for (feed=0; feed < feed_count; feed++) {
snprintf(tname, sizeof(tname),"%"PRIu16":%"PRIu16, adapter, feed);
feedName = SCStrdup(tname);
- if (feedName == NULL) {
- fprintf(stderr, "ERROR: Alloc feed name\n");
- exit(EXIT_FAILURE);
+ if (unlikely(feedName == NULL)) {
+ fprintf(stderr, "ERROR: Alloc feed name\n");
+ exit(EXIT_FAILURE);
}
snprintf(tname, sizeof(tname),"Feed%"PRIu16,feed);
threadName = SCStrdup(tname);
- if (threadName == NULL) {
- fprintf(stderr, "ERROR: Alloc thread name\n");
- exit(EXIT_FAILURE);
+ if (unlikely(threadName == NULL)) {
+ fprintf(stderr, "ERROR: Alloc thread name\n");
+ exit(EXIT_FAILURE);
}
snprintf(tname, sizeof(tname),"feed-queue%"PRIu16,feed);
outQueueName = SCStrdup(tname);
- if (outQueueName == NULL) {
- fprintf(stderr, "ERROR: Alloc output queue name\n");
- exit(EXIT_FAILURE);
+ if (unlikely(outQueueName == NULL)) {
+ fprintf(stderr, "ERROR: Alloc output queue name\n");
+ exit(EXIT_FAILURE);
}
/* create the threads */
{
snprintf(tname, sizeof(tname),"Detect%"PRIu16"/%"PRIu16,feed,detect++);
threadName = SCStrdup(tname);
- if (threadName == NULL) {
- fprintf(stderr, "ERROR: can not strdup thread name\n");
- exit(EXIT_FAILURE);
+ if (unlikely(threadName == NULL)) {
+ fprintf(stderr, "ERROR: can not strdup thread name\n");
+ exit(EXIT_FAILURE);
}
snprintf(tname, sizeof(tname),"feed-queue%"PRIu16,feed);
inQueueName = SCStrdup(tname);
- if (inQueueName == NULL) {
- fprintf(stderr, "ERROR: can not strdup in queue name\n");
- exit(EXIT_FAILURE);
+ if (unlikely(inQueueName == NULL)) {
+ fprintf(stderr, "ERROR: can not strdup in queue name\n");
+ exit(EXIT_FAILURE);
}
ThreadVars *tv_detect = TmThreadCreatePacketHandler(threadName,
TmSlotSetFuncAppend(tv_detect,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
- if (thread_group_name == NULL) {
- fprintf(stderr, "Error allocating memory\n");
- exit(EXIT_FAILURE);
+ if (unlikely(thread_group_name == NULL)) {
+ fprintf(stderr, "Error allocating memory\n");
+ exit(EXIT_FAILURE);
}
tv_detect->thread_group_name = thread_group_name;
SetupOutputs(tv_detect);
thread_group_name = SCStrdup("Outputs");
- if (thread_group_name == NULL) {
- fprintf(stderr, "Error allocating memory\n");
- exit(EXIT_FAILURE);
+ if (unlikely(thread_group_name == NULL)) {
+ fprintf(stderr, "Error allocating memory\n");
+ exit(EXIT_FAILURE);
}
tv_detect->thread_group_name = thread_group_name;
for (feed=0; feed < feed_count; feed++) {
snprintf(tname, sizeof(tname),"%"PRIu16":%"PRIu16, adapter, feed);
feedName = SCStrdup(tname);
- if (feedName == NULL) {
- fprintf(stderr, "ERROR: can not strdup feed name\n");
- exit(EXIT_FAILURE);
+ if (unlikely(feedName == NULL)) {
+ fprintf(stderr, "ERROR: can not strdup feed name\n");
+ exit(EXIT_FAILURE);
}
snprintf(tname, sizeof(tname),"Feed%"PRIu16,feed);
threadName = SCStrdup(tname);
- if (threadName == NULL) {
- fprintf(stderr, "ERROR: can not strdup in thread name\n");
- exit(EXIT_FAILURE);
+ if (unlikely(threadName == NULL)) {
+ fprintf(stderr, "ERROR: can not strdup in thread name\n");
+ exit(EXIT_FAILURE);
}
snprintf(tname, sizeof(tname),"feed-queue%"PRIu16,feed);
outQueueName = SCStrdup(tname);
- if (outQueueName == NULL) {
- fprintf(stderr, "ERROR: can not strdup out queue name\n");
- exit(EXIT_FAILURE);
+ if (unlikely(outQueueName == NULL)) {
+ fprintf(stderr, "ERROR: can not strdup out queue name\n");
+ exit(EXIT_FAILURE);
}
/* create the threads */
TmSlotSetFuncAppend(tv_napatechFeed,tm_module,(void *)de_ctx);
thread_group_name = SCStrdup("Detect");
- if (thread_group_name == NULL) {
- fprintf(stderr, "Error allocating memory\n");
- exit(EXIT_FAILURE);
+ if (unlikely(thread_group_name == NULL)) {
+ fprintf(stderr, "Error allocating memory\n");
+ exit(EXIT_FAILURE);
}
tv_napatechFeed->thread_group_name = thread_group_name;
SetupOutputs(tv_napatechFeed);
thread_group_name = SCStrdup("Outputs");
- if (thread_group_name == NULL) {
- fprintf(stderr, "Error allocating memory\n");
- exit(EXIT_FAILURE);
+ if (unlikely(thread_group_name == NULL)) {
+ fprintf(stderr, "Error allocating memory\n");
+ exit(EXIT_FAILURE);
}
tv_napatechFeed->thread_group_name = thread_group_name;
snprintf(tname, sizeof(tname), "Detect%"PRIu16, thread+1);
char *thread_name = SCStrdup(tname);
- if (thread_name == NULL) {
+ if (unlikely(thread_name == NULL)) {
printf("ERROR: Can not strdup thread name\n");
exit(EXIT_FAILURE);
}
TmThreadSetCPU(tv_detect_ncpu, DETECT_CPU_SET);
char *thread_group_name = SCStrdup("Detect");
- if (thread_group_name == NULL) {
+ if (unlikely(thread_group_name == NULL)) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
SCLogDebug("tname %s, qname %s", tname, qname);
char *thread_name = SCStrdup(tname);
- if (thread_name == NULL) {
+ if (unlikely(thread_name == NULL)) {
printf("ERROR: Can not strdup thread name\n");
exit(EXIT_FAILURE);
}
}
char *thread_group_name = SCStrdup("Detect");
- if (thread_group_name == NULL) {
+ if (unlikely(thread_group_name == NULL)) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
char *tmpctype;
intmax_t value;
- if (aconf == NULL) {
+ if (unlikely(aconf == NULL)) {
return NULL;
}
cluster_type default_ctype = CLUSTER_ROUND_ROBIN;
#endif
- if (pfconf == NULL) {
+ if (unlikely(pfconf == NULL)) {
return NULL;
}
char *bpf_filter = NULL;
#endif /* HAVE_PFRING_SET_BPF_FILTER */
- if (pfconf == NULL) {
+ if (unlikely(pfconf == NULL)) {
return NULL;
}
debuglog_enabled = 1;
RunModeOutput *runmode_output = SCCalloc(1, sizeof(RunModeOutput));
- if (runmode_output == NULL)
+ if (unlikely(runmode_output == NULL))
return;
runmode_output->tm_module = tm_module;
runmode_output->output_ctx = output_ctx;
AFPPeer *pitem;
int mtu, out_mtu;
- if (peer == NULL) {
+ if (unlikely(peer == NULL)) {
SCReturnInt(TM_ECODE_FAILED);
}
memset(peer, 0, sizeof(AFPPeer));
}
AFPThreadVars *ptv = SCMalloc(sizeof(AFPThreadVars));
- if (ptv == NULL) {
+ if (unlikely(ptv == NULL)) {
afpconfig->DerefFunc(afpconfig);
SCReturnInt(TM_ECODE_FAILED);
}
}
ErfDagThreadVars *ewtn = SCMalloc(sizeof(ErfDagThreadVars));
- if (ewtn == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "Failed to allocate memory for ERF DAG thread vars.");
+ if (unlikely(ewtn == NULL)) {
+ SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for ERF DAG thread vars.");
exit(EXIT_FAILURE);
}
}
ErfFileThreadVars *etv = SCMalloc(sizeof(ErfFileThreadVars));
- if (etv == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "Failed to allocate memory for ERF file thread vars.");
+ if (unlikely(etv == NULL)) {
+ SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate memory for ERF file thread vars.");
fclose(erf);
SCReturnInt(TM_ECODE_FAILED);
}
}
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);
}
SCLogInfo("reading pcap file %s", (char *)initdata);
PcapFileThreadVars *ptv = SCMalloc(sizeof(PcapFileThreadVars));
- if (ptv == NULL)
+ if (unlikely(ptv == NULL))
SCReturnInt(TM_ECODE_FAILED);
memset(ptv, 0, sizeof(PcapFileThreadVars));
}
PcapThreadVars *ptv = SCMalloc(sizeof(PcapThreadVars));
- if (ptv == NULL) {
+ if (unlikely(ptv == NULL)) {
pcapconfig->DerefFunc(pcapconfig);
SCReturnInt(TM_ECODE_FAILED);
}
}
PcapThreadVars *ptv = SCMalloc(sizeof(PcapThreadVars));
- if (ptv == NULL) {
- /* Dereference config */
+ if (unlikely(ptv == NULL)) {
pcapconfig->DerefFunc(pcapconfig);
SCReturnInt(TM_ECODE_FAILED);
}
return TM_ECODE_FAILED;
PfringThreadVars *ptv = SCMalloc(sizeof(PfringThreadVars));
- if (ptv == NULL) {
+ if (unlikely(ptv == NULL)) {
pfconf->DerefFunc(pfconf);
return TM_ECODE_FAILED;
}
p->tcph->th_seq = htonl(10000000UL);
t = SCMalloc(sizeof(TcpSegment));
- if (t == NULL) {
+ if (unlikely(t == NULL)) {
printf("alloc TcpSegment failed: ");
goto end;
}
p->tcph->th_seq = htonl(10000001UL);
t = SCMalloc(sizeof(TcpSegment));
- if (t == NULL) {
+ if (unlikely(t == NULL)) {
printf("alloc TcpSegment failed: ");
goto end;
}
p->tcph->th_seq = htonl(10000000UL);
t = SCMalloc(sizeof(TcpSegment));
- if (t == NULL) {
+ if (unlikely(t == NULL)) {
printf("alloc TcpSegment failed: ");
goto end;
}
p->tcph->th_seq = htonl(10000003UL);
t = SCMalloc(sizeof(TcpSegment));
- if (t == NULL) {
+ if (unlikely(t == NULL)) {
printf("alloc TcpSegment failed: ");
goto end;
}
p->tcph->th_seq = htonl(10000000UL);
t = SCMalloc(sizeof(TcpSegment));
- if (t == NULL) {
+ if (unlikely(t == NULL)) {
printf("alloc TcpSegment failed: ");
goto end;
}
p->tcph->th_seq = htonl(10000020UL);
t = SCMalloc(sizeof(TcpSegment));
- if (t == NULL) {
+ if (unlikely(t == NULL)) {
printf("alloc TcpSegment failed: ");
goto end;
}
p->tcph->th_seq = htonl(10000000UL);
t = SCMalloc(sizeof(TcpSegment));
- if (t == NULL) {
+ if (unlikely(t == NULL)) {
printf("alloc TcpSegment failed: ");
goto end;
}
TcpSegment *seg = NULL;
seg = SCMalloc(sizeof (TcpSegment));
- if (seg == NULL)
+ if (unlikely(seg == NULL))
return NULL;
return seg;
}
{
SCEnter();
TcpReassemblyThreadCtx *ra_ctx = SCMalloc(sizeof(TcpReassemblyThreadCtx));
- if (ra_ctx == NULL)
+ if (unlikely(ra_ctx == NULL))
return NULL;
memset(ra_ctx, 0x00, sizeof(TcpReassemblyThreadCtx));
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
uint8_t payload[4];
static int StreamTcpTestStartsBeforeListSegment(TcpStream *stream) {
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
uint8_t payload[4];
static int StreamTcpTestStartsAtSameListSegment(TcpStream *stream) {
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
uint8_t payload[4];
static int StreamTcpTestStartsAfterListSegment(TcpStream *stream) {
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
uint8_t payload[4];
uint16_t len, uint8_t th_flags, uint8_t flowflags, uint8_t state)
{
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return -1;
Flow f;
TCPHdr tcph;
static int StreamTcpReassembleTest32(void) {
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
TCPHdr tcph;
static int StreamTcpReassembleTest33(void) {
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
TCPHdr tcph;
static int StreamTcpReassembleTest34(void) {
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
TCPHdr tcph;
static int StreamTcpReassembleTest35(void) {
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
TCPHdr tcph;
static int StreamTcpReassembleTest36(void) {
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
TCPHdr tcph;
ThreadVars tv;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
StreamTcpInitConfig(TRUE);
static int StreamTcpReassembleTest38 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
TCPHdr tcph;
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow *f = NULL;
TCPHdr tcph;
static int StreamTcpReassembleTest40 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow *f = NULL;
TCPHdr tcph;
static int StreamTcpReassembleTest41 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow *f = NULL;
TCPHdr tcph;
static int StreamTcpReassembleTest42 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow *f = NULL;
TCPHdr tcph;
static int StreamTcpReassembleTest43 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow *f = NULL;
TCPHdr tcph;
static int StreamTcpReassembleTest45 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow *f = NULL;
TCPHdr tcph;
static int StreamTcpReassembleTest46 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow *f = NULL;
TCPHdr tcph;
static int StreamTcpReassembleTest47 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow *f = NULL;
TCPHdr tcph;
SCLogDebug("SEQ_LT(re, rec->le)");
// entirely before, prepend
StreamTcpSackRecord *stsr = SCMalloc(sizeof(StreamTcpSackRecord));
- if (stsr == NULL) {
+ if (unlikely(stsr == NULL)) {
SCReturnInt(-1);
}
stsr->le = le;
if (rec->next == NULL) {
SCLogDebug("rec->next == NULL");
StreamTcpSackRecord *stsr = SCMalloc(sizeof(StreamTcpSackRecord));
- if (stsr == NULL) {
+ if (unlikely(stsr == NULL)) {
SCReturnInt(-1);
}
stsr->le = le;
if (SEQ_LT(le, rec->next->le) && SEQ_LT(re, rec->next->le)) {
SCLogDebug("SEQ_LT(le, rec->next->le) && SEQ_LT(re, rec->next->le)");
StreamTcpSackRecord *stsr = SCMalloc(sizeof(StreamTcpSackRecord));
- if (stsr == NULL) {
+ if (unlikely(stsr == NULL)) {
SCReturnInt(-1);
}
stsr->le = le;
} else if (SEQ_LT(le, rec->next->le) && SEQ_GEQ(re, rec->next->le)) {
SCLogDebug("SEQ_LT(le, rec->next->le) && SEQ_GEQ(re, rec->next->le)");
StreamTcpSackRecord *stsr = SCMalloc(sizeof(StreamTcpSackRecord));
- if (stsr == NULL) {
+ if (unlikely(stsr == NULL)) {
SCReturnInt(-1);
}
stsr->le = le;
} else {
SCLogDebug("implied empty list");
StreamTcpSackRecord *stsr = SCMalloc(sizeof(StreamTcpSackRecord));
- if (stsr == NULL) {
+ if (unlikely(stsr == NULL)) {
SCReturnInt(-1);
}
stsr->le = le;
return NULL;
ptr = SCMalloc(sizeof(TcpSession));
- if (ptr == NULL)
+ if (unlikely(ptr == NULL))
return NULL;
return ptr;
{
SCEnter();
StreamTcpThread *stt = SCMalloc(sizeof(StreamTcpThread));
- if (stt == NULL)
+ if (unlikely(stt == NULL))
SCReturnInt(TM_ECODE_FAILED);
memset(stt, 0, sizeof(StreamTcpThread));
static int StreamTcpTest01 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
memset(p, 0, SIZE_OF_PACKET);
static int StreamTcpTest02 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
static int StreamTcpTest03 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
static int StreamTcpTest04 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
static int StreamTcpTest05 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
static int StreamTcpTest06 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
TcpSession ssn;
static int StreamTcpTest07 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
static int StreamTcpTest08 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
static int StreamTcpTest09 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
static int StreamTcpTest10 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
static int StreamTcpTest11 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
static int StreamTcpTest12 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
static int StreamTcpTest13 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
static int StreamTcpTest14 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
static int StreamTcp4WHSTest01 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
static int StreamTcp4WHSTest02 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
static int StreamTcp4WHSTest03 (void) {
int ret = 0;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
static int StreamTcpTest15 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
static int StreamTcpTest16 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
static int StreamTcpTest17 (void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
char *ip_addr;
TcpStream stream;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV4Hdr ipv4h;
int ret = 0;
char *ip_addr;
TcpStream stream;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV4Hdr ipv4h;
int ret = 0;
char *ip_addr;
TcpStream stream;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV4Hdr ipv4h;
int ret = 0;
char *ip_addr;
TcpStream stream;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV4Hdr ipv4h;
int ret = 0;
char *ip_addr;
TcpStream stream;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
IPV4Hdr ipv4h;
int ret = 0;
PacketQueue pq;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
memset(&pq,0,sizeof(PacketQueue));
{
TcpSession ssn;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
TCPHdr tcph;
*/
static int StreamTcpTest25(void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
*/
static int StreamTcpTest26(void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
*/
static int StreamTcpTest27(void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
*/
static int StreamTcpTest37(void) {
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
Flow f;
ThreadVars tv;
memset(&pq,0,sizeof(PacketQueue));
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
memset(&pq,0,sizeof(PacketQueue));
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
0x00, 0x04, 0xf0, 0xc8, 0x01, 0x99, 0xa3, 0xf3
};
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
0x04, 0x02, 0x08, 0x0a, 0x00, 0xdd, 0x1a, 0x39,
0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x03, 0x02 };
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return 0;
ThreadVars tv;
DecodeThreadVars dtv;
* \retval smq ptr to the queue or NULL */
StreamMsgQueue *StreamMsgQueueGetNew(void) {
StreamMsgQueue *smq = SCMalloc(sizeof(StreamMsgQueue));
- if (smq == NULL)
+ if (unlikely(smq == NULL))
return NULL;
memset(smq, 0x00, sizeof(StreamMsgQueue));
return;
bpf_filter = SCMalloc(bpf_len);
- if (bpf_filter == NULL)
+ if (unlikely(bpf_filter == NULL))
return;
memset(bpf_filter, 0x00, bpf_len);
}
bpf_filter = SCMalloc(bpf_len * sizeof(char));
- if (bpf_filter == NULL) {
- SCLogError(SC_ERR_MEM_ALLOC,
- "Failed to allocate buffer for bpf filter in file %s", filename);
+ if (unlikely(bpf_filter == NULL)) {
+ SCLogError(SC_ERR_MEM_ALLOC, "Failed to allocate buffer for bpf filter in file %s", filename);
exit(EXIT_FAILURE);
}
memset(bpf_filter, 0x00, bpf_len);
Tmq* TmqAlloc(void) {
Tmq *q = SCMalloc(sizeof(Tmq));
- if (q == NULL)
+ if (unlikely(q == NULL))
goto error;
memset(q, 0, sizeof(Tmq));
static inline TmSlot * _TmSlotSetFuncAppend(ThreadVars *tv, TmModule *tm, void *data)
{
TmSlot *slot = SCMalloc(sizeof(TmSlot));
- if (slot == NULL)
+ if (unlikely(slot == NULL))
return NULL;
memset(slot, 0, sizeof(TmSlot));
SC_ATOMIC_INIT(slot->slot_data);
}
dslot = SCMalloc(sizeof(TmDummySlot));
- if (dslot == NULL) {
+ if (unlikely(dslot == NULL)) {
return;
}
/* XXX create separate function for this: allocate a thread container */
tv = SCMalloc(sizeof(ThreadVars));
- if (tv == NULL)
+ if (unlikely(tv == NULL))
goto error;
memset(tv, 0, sizeof(ThreadVars));
return NULL;
TmqhFlowCtx *ctx = SCMalloc(sizeof(TmqhFlowCtx));
- if (ctx == NULL)
+ if (unlikely(ctx == NULL))
return NULL;
memset(ctx,0x00,sizeof(TmqhFlowCtx));
char *str = SCStrdup(queue_str);
- if (str == NULL) {
+ if (unlikely(str == NULL)) {
goto error;
}
char *tstr = str;
for (i = 0; i < max_pending_packets; i++) {
/* XXX pkt alloc function */
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL) {
+ if (unlikely(p == NULL)) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered while allocating a packet. Exiting...");
exit(EXIT_FAILURE);
}
/* setup the filter */
bf = SCMalloc(sizeof(BloomFilterCounting));
- if (bf == NULL)
+ if (unlikely(bf == NULL))
goto error;
memset(bf,0,sizeof(BloomFilterCounting));
bf->type = type; /* size of the type: 1, 2, 4 */
/* setup the filter */
bf = SCMalloc(sizeof(BloomFilter));
- if (bf == NULL)
+ if (unlikely(bf == NULL))
goto error;
memset(bf,0,sizeof(BloomFilter));
bf->bitarray_size = size;
uint32_t total_size = size + sizeof(MemBuffer);
MemBuffer *buffer = SCMalloc(total_size);
- if (buffer == NULL) {
+ if (unlikely(buffer == NULL)) {
return NULL;
}
memset(buffer, 0, total_size);
/* "mpm" profile, found under "cuda.mpm" in the conf file */
profile = SCMalloc(sizeof(SCCudaHlCudaProfile));
- if (profile == NULL) {
+ if (unlikely(profile == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
/* Register new CUmodule in the module */
new_module_cumodule = SCMalloc(sizeof(SCCudaHlModuleCUmodule));
- if (new_module_cumodule == NULL) {
+ if (unlikely(new_module_cumodule == NULL)) {
exit(EXIT_FAILURE);
}
memset(new_module_cumodule, 0, sizeof(SCCudaHlModuleCUmodule));
/* Register new CUmodule in the module */
new_module_cumodule = SCMalloc(sizeof(SCCudaHlModuleCUmodule));
- if (new_module_cumodule == NULL) {
+ if (unlikely(new_module_cumodule == NULL)) {
exit(EXIT_FAILURE);
}
memset(new_module_cumodule, 0, sizeof(SCCudaHlModuleCUmodule));
/* select the ptx image based on the compute capability supported by all
* devices (i.e. the lowest) */
char* image = SCMalloc(strlen(ptx_image)+15);
- if (image == NULL) {
+ if (unlikely(image == NULL)) {
exit(EXIT_FAILURE);
}
memset(image, 0x0, sizeof(image));
}
new_module_device_ptr = SCMalloc(sizeof(SCCudaHlModuleDevicePointer));
- if (new_module_device_ptr == NULL)
+ if (unlikely(new_module_device_ptr == NULL))
goto error;
memset(new_module_device_ptr, 0, sizeof(SCCudaHlModuleDevicePointer));
/* the module is not already registered. Register the module */
new_data = SCMalloc(sizeof(SCCudaHlModuleData));
- if (new_data == NULL) {
+ if (unlikely(new_data == NULL)) {
exit(EXIT_FAILURE);
}
memset(new_data, 0, sizeof(SCCudaHlModuleData));
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));
}
char *temp_fmt = SCStrdup(sc_log_config->log_format);
- if (temp_fmt == NULL) {
+ if (unlikely(temp_fmt == NULL)) {
return SC_ERR_MEM_ALLOC;
}
char *temp_fmt_h = temp_fmt;
log_dir = DEFAULT_LOG_DIR;
log_filename = SCMalloc(PATH_MAX);
- if (log_filename == NULL)
+ if (unlikely(log_filename == NULL))
return NULL;
snprintf(log_filename, PATH_MAX, "%s/%s", log_dir, filearg);
Asn1Ctx *SCAsn1CtxNew(void) {
Asn1Ctx *ac = SCMalloc(sizeof(Asn1Ctx));
- if (ac == NULL) {
+ if (unlikely(ac == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
return NULL;
}
int LiveRegisterDevice(char *dev)
{
LiveDevice *pd = SCMalloc(sizeof(LiveDevice));
- if (pd == NULL) {
+ if (unlikely(pd == NULL)) {
return -1;
}
*/
FileContainer *FileContainerAlloc(void) {
FileContainer *new = SCMalloc(sizeof(FileContainer));
- if (new == NULL) {
+ if (unlikely(new == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating mem");
return NULL;
}
*/
static FileData *FileDataAlloc(uint8_t *data, uint32_t data_len) {
FileData *new = SCMalloc(sizeof(FileData));
- if (new == NULL) {
+ if (unlikely(new == NULL)) {
return NULL;
}
memset(new, 0, sizeof(FileData));
*/
static File *FileAlloc(uint8_t *name, uint16_t name_len) {
File *new = SCMalloc(sizeof(File));
- if (new == NULL) {
+ if (unlikely(new == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating mem");
return NULL;
}
/* setup the filter */
ht = SCMalloc(sizeof(HashTable));
- if (ht == NULL)
- goto error;
+ if (unlikely(ht == NULL))
+ goto error;
memset(ht,0,sizeof(HashTable));
ht->array_size = size;
ht->Hash = Hash;
uint32_t hash = ht->Hash(ht, data, datalen);
HashTableBucket *hb = SCMalloc(sizeof(HashTableBucket));
- if (hb == NULL)
+ if (unlikely(hb == NULL))
goto error;
memset(hb, 0, sizeof(HashTableBucket));
hb->data = data;
/* setup the filter */
ht = SCMalloc(sizeof(HashListTable));
- if (ht == NULL)
- goto error;
+ if (unlikely(ht == NULL))
+ goto error;
memset(ht,0,sizeof(HashListTable));
ht->array_size = size;
ht->Hash = Hash;
SCLogDebug("ht %p hash %"PRIu32"", ht, hash);
HashListTableBucket *hb = SCMalloc(sizeof(HashListTableBucket));
- if (hb == NULL)
+ if (unlikely(hb == NULL))
goto error;
memset(hb, 0, sizeof(HashListTableBucket));
hb->data = data;
static inline SCACBSPattern *SCACBSAllocPattern(MpmCtx *mpm_ctx)
{
SCACBSPattern *p = SCMalloc(sizeof(SCACBSPattern));
- if (p == NULL) {
+ if (unlikely(p == NULL)) {
exit(EXIT_FAILURE);
}
memset(p, 0, sizeof(SCACBSPattern));
static inline SCACGfbsPattern *SCACGfbsAllocPattern(MpmCtx *mpm_ctx)
{
SCACGfbsPattern *p = SCMalloc(sizeof(SCACGfbsPattern));
- if (p == NULL) {
+ if (unlikely(p == NULL)) {
exit(EXIT_FAILURE);
}
memset(p, 0, sizeof(SCACGfbsPattern));
static inline SCACPattern *SCACAllocPattern(MpmCtx *mpm_ctx)
{
SCACPattern *p = SCMalloc(sizeof(SCACPattern));
- if (p == NULL) {
+ if (unlikely(p == NULL)) {
exit(EXIT_FAILURE);
}
memset(p, 0, sizeof(SCACPattern));
static inline B2gCudaPattern *B2gCudaAllocPattern(MpmCtx *mpm_ctx)
{
B2gCudaPattern *p = SCMalloc(sizeof(B2gCudaPattern));
- if (p == NULL)
+ if (unlikely(p == NULL))
return NULL;
memset(p, 0, sizeof(B2gCudaPattern));
static inline B2gCudaHashItem *B2gCudaAllocHashItem(MpmCtx *mpm_ctx)
{
B2gCudaHashItem *hi = SCMalloc(sizeof(B2gCudaHashItem));
- if (hi == NULL)
+ if (unlikely(hi == NULL))
return NULL;
memset(hi, 0, sizeof(B2gCudaHashItem));
}
B2gCudaMpmThreadCtxData *tctx = SCMalloc(sizeof(B2gCudaMpmThreadCtxData));
- if (tctx == NULL) {
+ if (unlikely(tctx == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
pb->packets_payload_offset_buffer[0] = 0;
p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
goto end;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
*/
static inline B2gPattern *B2gAllocPattern(MpmCtx *mpm_ctx) {
B2gPattern *p = SCMalloc(sizeof(B2gPattern));
- if (p == NULL)
+ if (unlikely(p == NULL))
return NULL;
memset(p,0,sizeof(B2gPattern));
static inline B2gPattern *
B2gAllocHashItem(MpmCtx *mpm_ctx) {
B2gPattern *hi = SCMalloc(sizeof(B2gPattern));
- if (hi == NULL)
+ if (unlikely(hi == NULL))
return NULL;
memset(hi,0,sizeof(B2gPattern));
static inline B2gcPattern *B2gcAllocPattern(MpmCtx *mpm_ctx) {
B2gcPattern *p = SCMalloc(sizeof(B2gcPattern));
- if (p == NULL)
+ if (unlikely(p == NULL))
return NULL;
memset(p,0,sizeof(B2gcPattern));
static inline B2gmPattern *B2gmAllocPattern(MpmCtx *mpm_ctx) {
B2gmPattern *p = SCMalloc(sizeof(B2gmPattern));
- if (p == NULL)
+ if (unlikely(p == NULL))
return NULL;
memset(p,0,sizeof(B2gmPattern));
static inline B2gmPattern *
B2gmAllocHashItem(MpmCtx *mpm_ctx) {
B2gmPattern *hi = SCMalloc(sizeof(B2gmPattern));
- if (hi == NULL)
+ if (unlikely(hi == NULL))
return NULL;
memset(hi,0,sizeof(B2gmPattern));
static inline B3gPattern *B3gAllocPattern(MpmCtx *mpm_ctx) {
B3gPattern *p = SCMalloc(sizeof(B3gPattern));
- if (p == NULL)
+ if (unlikely(p == NULL))
return NULL;
memset(p,0,sizeof(B3gPattern));
static inline B3gHashItem *
B3gAllocHashItem(MpmCtx *mpm_ctx) {
B3gHashItem *hi = SCMalloc(sizeof(B3gHashItem));
- if (hi == NULL)
+ if (unlikely(hi == NULL))
return NULL;
memset(hi,0,sizeof(B3gHashItem));
static inline WmPattern *WmAllocPattern(MpmCtx *mpm_ctx) {
WmPattern *p = SCMalloc(sizeof(WmPattern));
- if (p == NULL)
+ if (unlikely(p == NULL))
return NULL;
memset(p,0,sizeof(WmPattern));
static inline WmHashItem *
WmAllocHashItem(MpmCtx *mpm_ctx) {
WmHashItem *hi = SCMalloc(sizeof(WmHashItem));
- if (hi == NULL)
+ if (unlikely(hi == NULL))
return NULL;
memset(hi,0,sizeof(WmHashItem));
memset(de_ctx->mpm_ctx_factory_container, 0, sizeof(MpmCtxFactoryContainer));
MpmCtxFactoryItem *item = SCMalloc(sizeof(MpmCtxFactoryItem));
- if (item == NULL) {
+ if (unlikely(item == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
{
if (id == MPM_CTX_FACTORY_UNIQUE_CONTEXT) {
MpmCtx *mpm_ctx = SCMalloc(sizeof(MpmCtx));
- if (mpm_ctx == NULL) {
+ if (unlikely(mpm_ctx == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
exit(EXIT_FAILURE);
}
/* setup the filter */
p = SCMalloc(sizeof(Pool));
- if (p == NULL)
+ if (unlikely(p == NULL))
goto error;
memset(p,0,sizeof(Pool));
for (u32 = 0; u32 < prealloc_size; u32++) {
if (size == 0) { /* unlimited */
PoolBucket *pb = SCMalloc(sizeof(PoolBucket));
- if (pb == NULL)
+ if (unlikely(pb == NULL))
goto error;
memset(pb, 0, sizeof(PoolBucket));
void *PoolTestAlloc() {
void *ptr = SCMalloc(10);
- if (ptr == NULL)
+ if (unlikely(ptr == NULL))
return NULL;
return ptr;
}
log_dir = DEFAULT_LOG_DIR;
profiling_file_name = SCMalloc(PATH_MAX);
- if (profiling_file_name == NULL) {
+ if (unlikely(profiling_file_name == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "can't duplicate file name");
exit(EXIT_FAILURE);
}
int summary_size = sizeof(SCProfileSummary) * rules_ctx->size;
SCProfileSummary *summary = SCMalloc(summary_size);
- if (summary == NULL) {
+ if (unlikely(summary == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory for profiling summary");
return;
}
log_dir = DEFAULT_LOG_DIR;
profiling_packets_file_name = SCMalloc(PATH_MAX);
- if (profiling_packets_file_name == NULL) {
+ if (unlikely(profiling_packets_file_name == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "can't duplicate file name");
exit(EXIT_FAILURE);
}
log_dir = DEFAULT_LOG_DIR;
profiling_csv_file_name = SCMalloc(PATH_MAX);
- if (profiling_csv_file_name == NULL) {
+ if (unlikely(profiling_csv_file_name == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "out of memory");
exit(EXIT_FAILURE);
}
log_dir = DEFAULT_LOG_DIR;
profiling_locks_file_name = SCMalloc(PATH_MAX);
- if (profiling_locks_file_name == NULL) {
+ if (unlikely(profiling_locks_file_name == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "can't duplicate file name");
exit(EXIT_FAILURE);
}
static SCRadixUserData *SCRadixAllocSCRadixUserData(uint8_t netmask, void *user)
{
SCRadixUserData *user_data = SCMalloc(sizeof(SCRadixUserData));
- if (user_data == NULL) {
+ if (unlikely(user_data == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
return NULL;
}
for (; i <= 32; i++) {
user = SCMalloc(sizeof(uint32_t));
- if (user == NULL) {
+ if (unlikely(user == NULL)) {
result = 0;
goto end;
}
for (; i <= 32; i++) {
user = SCMalloc(sizeof(uint32_t));
- if (user == NULL) {
+ if (unlikely(user == NULL)) {
result = 0;
goto end;
}
for (; i <= 32; i++) {
user = SCMalloc(sizeof(uint32_t));
- if (user == NULL) {
+ if (unlikely(user == NULL)) {
result = 0;
goto end;
}
for (; i <= 32; i++) {
user = SCMalloc(sizeof(uint32_t));
- if (user == NULL) {
+ if (unlikely(user == NULL)) {
result = 0;
goto end;
}
}
user = SCMalloc(sizeof(uint32_t));
- if (user == NULL) {
+ if (unlikely(user == NULL)) {
result = 0;
goto end;
}
}
user = SCMalloc(sizeof(uint32_t));
- if (user == NULL) {
+ if (unlikely(user == NULL)) {
result = 0;
goto end;
}
}
user = SCMalloc(sizeof(uint32_t));
- if (user == NULL) {
+ if (unlikely(user == NULL)) {
result = 0;
goto end;
}
for (; i <= 128; i++) {
user = SCMalloc(sizeof(uint32_t));
- if (user == NULL) {
+ if (unlikely(user == NULL)) {
result = 0;
goto end;
}
for (; i <= 128; i++) {
user = SCMalloc(sizeof(uint32_t));
- if (user == NULL) {
+ if (unlikely(user == NULL)) {
result = 0;
goto end;
}
for (; i <= 128; i++) {
user = SCMalloc(sizeof(uint32_t));
- if (user == NULL) {
+ if (unlikely(user == NULL)) {
result = 0;
goto end;
}
for (; i <= 128; i++) {
user = SCMalloc(sizeof(uint32_t));
- if (user == NULL) {
+ if (unlikely(user == NULL)) {
result = 0;
goto end;
}
}
user = SCMalloc(sizeof(uint32_t));
- if (user == NULL) {
+ if (unlikely(user == NULL)) {
result = 0;
goto end;
}
}
user = SCMalloc(sizeof(uint32_t));
- if (user == NULL) {
+ if (unlikely(user == NULL)) {
result = 0;
goto end;
}
}
user = SCMalloc(sizeof(uint32_t));
- if (user == NULL) {
+ if (unlikely(user == NULL)) {
result = 0;
goto end;
}
static int SCRadixTestUserdataMacro01(void) {
int result = 0;
SCRadixNode *node = SCMalloc(sizeof(SCRadixNode));
- if (node == NULL) {
+ if (unlikely(node == NULL)) {
goto end;
}
memset(node, 0x00, sizeof(*node));
SCRadixPrefix prefix;
int result = 0;
SCRadixNode *node = SCMalloc(sizeof(SCRadixNode));
- if (node == NULL) {
+ if (unlikely(node == NULL)) {
goto end;
}
memset(node, 0x00, sizeof(*node));
int result = 0;
void *somep = &result;
SCRadixNode *node = SCMalloc(sizeof(SCRadixNode));
- if (node == NULL) {
+ if (unlikely(node == NULL)) {
goto end;
}
memset(node, 0x00, sizeof(*node));
RingBuffer8 *RingBuffer8Init(void) {
RingBuffer8 *rb = SCMalloc(sizeof(RingBuffer8));
- if (rb == NULL) {
+ if (unlikely(rb == NULL)) {
return NULL;
}
RingBuffer16 *RingBufferInit(void) {
RingBuffer16 *rb = SCMalloc(sizeof(RingBuffer16));
- if (rb == NULL) {
+ if (unlikely(rb == NULL)) {
return NULL;
}
uint32_t size = hashsize(hash_bits) * sizeof(ROHashTableOffsets);
ROHashTable *table = SCMalloc(sizeof(ROHashTable) + size);
- if (table == NULL) {
+ if (unlikely(table == NULL)) {
SCLogError(SC_ERR_HASH_TABLE_INIT, "failed to alloc memory");
return NULL;
}
snprintf(tname, sizeof(tname),"%s-%s", thread_name, live_dev);
tnamec = SCStrdup(tname);
- if (tnamec == NULL) {
+ if (unlikely(tnamec == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate thread name");
exit(EXIT_FAILURE);
}
char *thread_name = SCStrdup(tname);
- if (thread_name == NULL) {
+ if (unlikely(thread_name == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate thread name");
exit(EXIT_FAILURE);
}
TmThreadSetCPU(tv_detect_ncpu, DETECT_CPU_SET);
char *thread_group_name = SCStrdup("Detect");
- if (thread_group_name == NULL) {
+ if (unlikely(thread_group_name == NULL)) {
SCLogError(SC_ERR_RUNMODE, "Error allocating memory");
exit(EXIT_FAILURE);
}
for (thread = 0; thread < threads_count; thread++) {
snprintf(tname, sizeof(tname), "%s%"PRIu16, thread_name, thread+1);
char *thread_name = SCStrdup(tname);
- if (thread_name == NULL) {
+ if (unlikely(thread_name == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate thread name");
exit(EXIT_FAILURE);
}
snprintf(tname, sizeof(tname), "%s%s%"PRIu16, thread_name,
live_dev, thread+1);
char *thread_name = SCStrdup(tname);
- if (thread_name == NULL) {
+ if (unlikely(thread_name == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate thread name");
exit(EXIT_FAILURE);
}
SCLogDebug("tname %s, qname %s", tname, qname);
char *thread_name = SCStrdup(tname);
- if (thread_name == NULL) {
+ if (unlikely(thread_name == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate thread name");
exit(EXIT_FAILURE);
}
TmThreadSetCPU(tv_detect_ncpu, DETECT_CPU_SET);
char *thread_group_name = SCStrdup("Detect");
- if (thread_group_name == NULL) {
+ if (unlikely(thread_group_name == NULL)) {
SCLogError(SC_ERR_RUNMODE, "Error allocating memory");
exit(EXIT_FAILURE);
}
thread_name, live_dev, thread+1);
}
n_thread_name = SCStrdup(tname);
- if (n_thread_name == NULL) {
+ if (unlikely(n_thread_name == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate thread name");
exit(EXIT_FAILURE);
}
if (live_dev != NULL) {
aconf = ConfigParser(live_dev);
live_dev_c = SCStrdup(live_dev);
- if (live_dev_c == NULL) {
+ if (unlikely(live_dev_c == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate interface name");
exit(EXIT_FAILURE);
}
TmThreadSetCPU(tv_detect_ncpu, DETECT_CPU_SET);
char *thread_group_name = SCStrdup("Detect");
- if (thread_group_name == NULL) {
+ if (unlikely(thread_group_name == NULL)) {
printf("Error allocating memory\n");
exit(EXIT_FAILURE);
}
SCLogDebug("tname %s, qname %s", tname, qname);
char *thread_name = SCStrdup(tname);
- if (thread_name == NULL) {
+ if (unlikely(thread_name == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Can't allocate thread name");
exit(EXIT_FAILURE);
}
SetupOutputs(tv_detect_ncpu);
char *thread_group_name = SCStrdup("Detect");
- if (thread_group_name == NULL) {
+ if (unlikely(thread_group_name == NULL)) {
SCLogError(SC_ERR_RUNMODE, "Error allocating memory");
exit(EXIT_FAILURE);
}
*/
BmCtx *BoyerMooreCtxInit(uint8_t *needle, uint16_t needle_len) {
BmCtx *new = SCMalloc(sizeof(BmCtx));
- if (new == NULL) {
+ if (unlikely(new == NULL)) {
SCLogError(SC_ERR_FATAL, "Fatal error encountered in BoyerMooreCtxInit. Exiting...");
exit(EXIT_FAILURE);
}
uint16_t *suff;
suff = SCMalloc(sizeof(uint16_t) * (m + 1));
- if (suff == NULL)
+ if (unlikely(suff == NULL))
return -1;
BoyerMooreSuffixes(x, m, suff);
uint16_t* suff;
suff = SCMalloc(sizeof(uint16_t) * (m + 1));
- if (suff == NULL)
+ if (unlikely(suff == NULL))
return;
BoyerMooreSuffixesNocase(x, m, suff);
uint8_t *BoyerMooreSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen) {
uint16_t bmBc[ALPHABET_SIZE];
uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1));
- if (bmGs == NULL)
+ if (unlikely(bmGs == NULL))
return NULL;
PreBmGs(needle, needlelen, bmGs);
uint8_t *BoyerMooreNocaseSearch(uint8_t *text, uint32_t textlen, uint8_t *needle, uint16_t needlelen) {
uint16_t bmBc[ALPHABET_SIZE];
uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1));
- if (bmGs == NULL)
+ if (unlikely(bmGs == NULL))
return NULL;
PreBmGsNocase(needle, needlelen, bmGs);
uint16_t bmBc[ALPHABET_SIZE];
uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1));
- if (bmGs == NULL)
+ if (unlikely(bmGs == NULL))
return NULL;
uint8_t *ret = NULL;
uint16_t bmBc[ALPHABET_SIZE];
uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1));
- if (bmGs == NULL)
+ if (unlikely(bmGs == NULL))
return NULL;
uint8_t *ret = NULL;
uint16_t bmBc[ALPHABET_SIZE];
uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1));
- if (bmGs == NULL)
+ if (unlikely(bmGs == NULL))
return NULL;
uint8_t *ret = NULL;
uint16_t bmBc[ALPHABET_SIZE];
uint16_t *bmGs = SCMalloc(sizeof(uint16_t)*(needlelen + 1));
- if (bmGs == NULL)
+ if (unlikely(bmGs == NULL))
return NULL;
uint8_t *ret = NULL;
}
de = SCMalloc(sizeof(DetectThresholdData));
- if (de == NULL)
+ if (unlikely(de == NULL))
goto error;
memset(de,0,sizeof(DetectThresholdData));
}
de = SCMalloc(sizeof(DetectThresholdData));
- if (de == NULL)
+ if (unlikely(de == NULL))
goto error;
memset(de,0,sizeof(DetectThresholdData));
}
de = SCMalloc(sizeof(DetectThresholdData));
- if (de == NULL)
+ if (unlikely(de == NULL))
goto error;
memset(de,0,sizeof(DetectThresholdData));
uint32_t in[4];
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return NULL;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
struct in_addr in;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return NULL;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = ((uint8_t *)p) + sizeof(*p);
}
Packet **p = NULL;
p = SCMalloc(sizeof(Packet *) * numpkts);
- if (p == NULL)
+ if (unlikely(p == NULL))
return NULL;
memset(&dtv, 0, sizeof(DecodeThreadVars));
DecodeThreadVars dtv;
ThreadVars th_v;
Packet *p = SCMalloc(SIZE_OF_PACKET);
- if (p == NULL)
+ if (unlikely(p == NULL))
return NULL;
memset(p, 0, SIZE_OF_PACKET);
p->pkt = (uint8_t *)(p + 1);
struct in_addr in;
Flow *f = SCMalloc(sizeof(Flow));
- if (f == NULL) {
- printf("FlowAlloc failed\n");;
+ if (unlikely(f == NULL)) {
+ printf("FlowAlloc failed\n");
+ ;
return NULL;
}
memset(f, 0x00, sizeof(Flow));
static UtTest *UtAllocTest(void) {
UtTest *ut = SCMalloc(sizeof(UtTest));
- if (ut == NULL)
+ if (unlikely(ut == NULL))
return NULL;
memset(ut, 0, sizeof(UtTest));
uint16_t idx = 0;
VariableName *fn = SCMalloc(sizeof(VariableName));
- if (fn == NULL)
+ if (unlikely(fn == NULL))
goto error;
memset(fn, 0, sizeof(VariableName));
char *VariableIdxGetName(DetectEngineCtx *de_ctx, uint16_t idx, uint8_t type)
{
VariableName *fn = SCMalloc(sizeof(VariableName));
- if (fn == NULL)
+ if (unlikely(fn == NULL))
goto error;
char *name = NULL;
VariableName *lookup_fn = (VariableName *)HashListTableLookup(de_ctx->variable_idxs, (void *)fn, 0);
if (lookup_fn != NULL) {
name = SCStrdup(lookup_fn->name);
- if (name == NULL)
+ if (unlikely(name == NULL))
goto error;
VariableNameFree(fn);
{
if (overwrite || NULL == getenv(name)) {
char *str = SCMalloc(strlen(name) + strlen(value) + 2);
- if (str == NULL)
+ if (unlikely(str == NULL))
return;
snprintf(str, strlen(name) + strlen(value) + 1, "%s=%s", name, value);
putenv(str);
void unsetenv(const char *name)
{
char *str = SCMalloc(strlen(name) + 2);
- if (str == NULL)
+ if (unlikely(str == NULL))
return;
snprintf(str, strlen(name) + 1, "%s=", name);
putenv(str);