From 5919901675fd331752c3d094962af0fdada7dc5e Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 14 Mar 2013 11:59:38 +0100 Subject: [PATCH] Storage API: add registration check closed test in debug mode. --- src/util-storage.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/util-storage.c b/src/util-storage.c index 31ba17fdbb..b534ca191b 100644 --- a/src/util-storage.c +++ b/src/util-storage.c @@ -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++) {