]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
storage: fix and small optimization
authorVictor Julien <victor@inliniac.net>
Fri, 18 Oct 2013 18:09:09 +0000 (20:09 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 18 Oct 2013 18:09:09 +0000 (20:09 +0200)
src/util-storage.c

index 6bf3603bf06765b993a5f795abfc0ace8ad333c1..8a858fb78cea3c72d2abce248da9f31b5246d58b 100644 (file)
@@ -288,11 +288,11 @@ void StorageFreeById(Storage *storage, StorageEnum type, int id)
 #endif
     SCLogDebug("storage %p id %d", storage, id);
 
-    StorageMapping *map = &storage_map[type][id];
     Storage *store = storage;
     if (store != NULL) {
         SCLogDebug("store %p", store);
         if (store[id] != NULL) {
+            StorageMapping *map = &storage_map[type][id];
             map->Free(store[id]);
             store[id] = NULL;
         }
@@ -314,8 +314,8 @@ void StorageFreeAll(Storage *storage, StorageEnum type)
     Storage *store = storage;
     int i;
     for (i = 0; i < storage_max_id[type]; i++) {
-        StorageMapping *map = &storage_map[type][i];
         if (store[i] != NULL) {
+            StorageMapping *map = &storage_map[type][i];
             map->Free(store[i]);
             store[i] = NULL;
         }
@@ -338,14 +338,14 @@ void StorageFree(Storage **storage, StorageEnum type)
     Storage *store = *storage;
     int i;
     for (i = 0; i < storage_max_id[type]; i++) {
-        StorageMapping *map = &storage_map[type][i];
         if (store[i] != NULL) {
+            StorageMapping *map = &storage_map[type][i];
             map->Free(store[i]);
             store[i] = NULL;
         }
     }
     SCFree(*storage);
-    storage = NULL;
+    *storage = NULL;
 }
 
 #ifdef UNITTESTS