]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Storage API: add registration check closed test in debug mode.
authorVictor Julien <victor@inliniac.net>
Thu, 14 Mar 2013 10:59:38 +0000 (11:59 +0100)
committerVictor Julien <victor@inliniac.net>
Sun, 28 Jul 2013 21:41:11 +0000 (23:41 +0200)
src/util-storage.c

index 31ba17fdbb7d0b872f9b165c2aacbced1150cb46..b534ca191b3ae60000f2482460d7f2bd9df656fd 100644 (file)
@@ -200,6 +200,9 @@ unsigned int StorageGetSize(StorageEnum type) {
 }
 
 void *StorageGetById(const Storage *storage, const StorageEnum type, const int id) {
+#ifdef DEBUG
+    BUG_ON(!storage_registraton_closed);
+#endif
     SCLogDebug("storage %p id %d", storage, id);
     if (storage == NULL)
         return NULL;
@@ -207,6 +210,9 @@ void *StorageGetById(const Storage *storage, const StorageEnum type, const int i
 }
 
 int StorageSetById(Storage *storage, const StorageEnum type, const int id, void *ptr) {
+#ifdef DEBUG
+    BUG_ON(!storage_registraton_closed);
+#endif
     SCLogDebug("storage %p id %d", storage, id);
     if (storage == NULL)
         return -1;
@@ -215,6 +221,9 @@ int StorageSetById(Storage *storage, const StorageEnum type, const int id, void
 }
 
 void *StorageAllocByIdPrealloc(Storage *storage, StorageEnum type, int id) {
+#ifdef DEBUG
+    BUG_ON(!storage_registraton_closed);
+#endif
     SCLogDebug("storage %p id %d", storage, id);
 
     StorageMapping *map = &storage_map[type][id];
@@ -229,6 +238,9 @@ void *StorageAllocByIdPrealloc(Storage *storage, StorageEnum type, int id) {
 }
 
 void *StorageAllocById(Storage **storage, StorageEnum type, int id) {
+#ifdef DEBUG
+    BUG_ON(!storage_registraton_closed);
+#endif
     SCLogDebug("storage %p id %d", storage, id);
 
     StorageMapping *map = &storage_map[type][id];
@@ -255,6 +267,9 @@ void *StorageAllocById(Storage **storage, StorageEnum type, int id) {
 }
 
 void StorageFreeById(Storage *storage, StorageEnum type, int id) {
+#ifdef DEBUG
+    BUG_ON(!storage_registraton_closed);
+#endif
     SCLogDebug("storage %p id %d", storage, id);
 
     StorageMapping *map = &storage_map[type][id];
@@ -272,6 +287,10 @@ void StorageFreeAll(Storage *storage, StorageEnum type) {
     if (*storage == NULL)
         return;
 
+#ifdef DEBUG
+    BUG_ON(!storage_registraton_closed);
+#endif
+
     Storage *store = storage;
     int i;
     for (i = 0; i < storage_max_id[type]; i++) {
@@ -287,6 +306,10 @@ void StorageFree(Storage **storage, StorageEnum type) {
     if (*storage == NULL)
         return;
 
+#ifdef DEBUG
+    BUG_ON(!storage_registraton_closed);
+#endif
+
     Storage *store = *storage;
     int i;
     for (i = 0; i < storage_max_id[type]; i++) {