return(temp->id);
/* if we reach this point we don't have a counter registered by this name */
- if ( (pc = SCMalloc(sizeof(StatsCounter))) == NULL)
+ if ((pc = SCCalloc(1, sizeof(StatsCounter))) == NULL)
return 0;
- memset(pc, 0, sizeof(StatsCounter));
/* assign a unique id to this StatsCounter. The id is local to this
* thread context. Please note that the id start from 1, and not 0 */
void StatsInit(void)
{
BUG_ON(stats_ctx != NULL);
- if ( (stats_ctx = SCMalloc(sizeof(StatsGlobalContext))) == NULL) {
+ if ((stats_ctx = SCCalloc(1, sizeof(StatsGlobalContext))) == NULL) {
FatalError("Fatal error encountered in StatsInitCtx. Exiting...");
}
- memset(stats_ctx, 0, sizeof(StatsGlobalContext));
StatsPublicThreadContextInit(&stats_ctx->global_counter_ctx);
}
StatsThreadStore *temp = NULL;
- if ( (temp = SCMalloc(sizeof(StatsThreadStore))) == NULL) {
+ if ((temp = SCCalloc(1, sizeof(StatsThreadStore))) == NULL) {
SCMutexUnlock(&stats_ctx->sts_lock);
return 0;
}
- memset(temp, 0, sizeof(StatsThreadStore));
temp->ctx = pctx;
temp->name = thread_name;
return -1;
}
- if ( (pca->head = SCMalloc(sizeof(StatsLocalCounter) * (e_id - s_id + 2))) == NULL) {
+ if ((pca->head = SCCalloc(1, sizeof(StatsLocalCounter) * (e_id - s_id + 2))) == NULL) {
return -1;
}
- memset(pca->head, 0, sizeof(StatsLocalCounter) * (e_id - s_id + 2));
pc = pctx->head;
while (pc->id != s_id)