]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Counters: merge SCPerfCounterName into SCPerfCounter as there was a 1 on 1 mapping
authorVictor Julien <victor@inliniac.net>
Tue, 29 Oct 2013 07:19:16 +0000 (08:19 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 29 Oct 2013 07:19:16 +0000 (08:19 +0100)
src/counters.c
src/counters.h

index 00f69cfc56ca44a3bef3c4e708d176713a979645..5283ef7cee58975bba5e3addfb5c573d38e5dbdd 100644 (file)
@@ -463,15 +463,12 @@ static void *SCPerfWakeupThread(void *arg)
 static void SCPerfReleaseCounter(SCPerfCounter *pc)
 {
     if (pc != NULL) {
-        if (pc->name != NULL) {
-            if (pc->name->cname != NULL)
-                SCFree(pc->name->cname);
+        if (pc->cname != NULL)
+            SCFree(pc->cname);
 
-            if (pc->name->tm_name != NULL)
-                SCFree(pc->name->tm_name);
+        if (pc->tm_name != NULL)
+            SCFree(pc->tm_name);
 
-            SCFree(pc->name);
-        }
         if (pc->desc != NULL)
             SCFree(pc->desc);
 
@@ -519,8 +516,8 @@ static uint16_t SCPerfRegisterQualifiedCounter(char *cname, char *tm_name,
     while (temp != NULL) {
         prev = temp;
 
-        if (strcmp(cname, temp->name->cname) == 0 &&
-            strcmp(tm_name, temp->name->tm_name) == 0) {
+        if (strcmp(cname, temp->cname) == 0 &&
+            strcmp(tm_name, temp->tm_name) == 0) {
             break;
         }
 
@@ -536,17 +533,12 @@ static uint16_t SCPerfRegisterQualifiedCounter(char *cname, char *tm_name,
         return 0;
     memset(pc, 0, sizeof(SCPerfCounter));
 
-    if ( (pc->name = SCMalloc(sizeof(SCPerfCounterName))) == NULL) {
-        SCFree(pc);
-        return 0;
-    }
-    memset(pc->name, 0, sizeof(SCPerfCounterName));
-    if ( (pc->name->cname = SCStrdup(cname)) == NULL) {
+    if ( (pc->cname = SCStrdup(cname)) == NULL) {
         SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
         exit(EXIT_FAILURE);
     }
 
-    if ( (pc->name->tm_name = SCStrdup(tm_name)) == NULL) {
+    if ( (pc->tm_name = SCStrdup(tm_name)) == NULL) {
         SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
         exit(EXIT_FAILURE);
     }
@@ -678,7 +670,7 @@ static int SCPerfOutputCounterFileIface()
 
             SCMutexLock(&pctmi->head[u]->m);
 
-            while(pc_heads[u] != NULL && strcmp(pctmi->tm_name, pc_heads[u]->name->tm_name)) {
+            while(pc_heads[u] != NULL && strcmp(pctmi->tm_name, pc_heads[u]->tm_name)) {
                 pc_heads[u] = pc_heads[u]->next;
             }
         }
@@ -701,7 +693,7 @@ static int SCPerfOutputCounterFileIface()
             }
 
             fprintf(sc_perf_op_ctx->fp, "%-25s | %-25s | %-" PRIu64 "\n",
-                    pc->name->cname, pctmi->tm_name, ui64_result);
+                    pc->cname, pctmi->tm_name, ui64_result);
         }
 
         for (u = 0; u < pctmi->size; u++)
index 7aa585d922a7dda8d219f4406d5c6117cfc162be..64efcb2a3c58a45eb3cef69848d9a62a66ab61e0 100644 (file)
@@ -81,11 +81,14 @@ typedef struct SCPerfCounter_ {
 
     uint64_t value;
 
-    SCPerfCounterName *name;
-
     /* no of times the local counter has been synced with this counter */
     uint64_t updated;
 
+    /* name of the counter */
+    char *cname;
+    /* name of the thread module this counter is registered to */
+    char *tm_name;
+
     /* the next perfcounter for this tv's tm instance */
     struct SCPerfCounter_ *next;