Go to the documentation of this file.
35 void *(*Alloc)(
unsigned int);
48 static int storage_registration_closed = 0;
72 memset(&storage_max_id, 0x00,
sizeof(storage_max_id));
75 storage_registration_closed = 0;
83 if (storage_map[i] != NULL) {
85 storage_map[i] = NULL;
104 if (storage_registration_closed)
108 size == 0 || (size !=
sizeof(
void *) && Alloc == NULL) || Free == NULL)
115 "name \"%s\" already registered",
116 StoragePrintType(
type), name);
133 entry->
id = storage_max_id[
type]++;
134 entry->
next = storage_list;
135 storage_list = entry;
145 storage_registration_closed = 1;
148 if (storage_max_id[i] > 0)
155 if (
unlikely(storage_map == NULL)) {
160 if (storage_max_id[i] > 0) {
162 if (storage_map[i] == NULL)
169 if (storage_map[entry->
map.
type] != NULL) {
185 if (storage_map[i] == NULL)
189 for (j = 0; j < storage_max_id[i]; j++) {
191 SCLogDebug(
"type \"%s\" name \"%s\" size \"%"PRIuMAX
"\"",
192 StoragePrintType(
m->type),
m->name, (uintmax_t)
m->size);
201 return storage_max_id[
type];
212 return storage_max_id[
type] *
sizeof(
void *);
218 BUG_ON(!storage_registration_closed);
223 return storage[
id].
ptr;
229 BUG_ON(!storage_registration_closed);
234 storage[
id].
ptr = ptr;
241 BUG_ON(!storage_registration_closed);
246 if (storage[
id].ptr == NULL &&
map->
Alloc != NULL) {
248 if (storage[
id].ptr == NULL) {
253 return storage[
id].
ptr;
259 BUG_ON(!storage_registration_closed);
262 if (storage_map == NULL)
270 if (store[
id].ptr != NULL) {
273 store[
id].
ptr = NULL;
283 BUG_ON(!storage_registration_closed);
286 if (storage_map == NULL)
292 for (i = 0; i < storage_max_id[
type]; i++) {
293 if (store[i].ptr != NULL) {
void StorageFreeAll(Storage *storage, StorageEnum type)
struct StorageList_ * next
struct HtpBodyChunk_ * next
void StorageCleanup(void)
enum StorageEnum_ StorageEnum
struct StorageList_ StorageList
list of StorageMapping used at registration time
int StorageFinalize(void)
unsigned int StorageGetCnt(StorageEnum type)
int StorageSetById(Storage *storage, const StorageEnum type, const int id, void *ptr)
set storage for id
void * StorageAllocByIdPrealloc(Storage *storage, StorageEnum type, int id)
AllocById func for prealloc'd base storage (storage ptrs are part of another memory block)
void StorageFreeById(Storage *storage, StorageEnum type, int id)
#define SCLogError(...)
Macro used to log ERROR messages.
void * StorageGetById(const Storage *storage, const StorageEnum type, const int id)
get storage for id
void *(* Alloc)(unsigned int)
unsigned int StorageGetSize(StorageEnum type)
get the size of the void array used to store the pointers
int StorageRegister(const StorageEnum type, const char *name, const unsigned int size, void *(*Alloc)(unsigned int), void(*Free)(void *))
Register new storage.
struct StorageMapping_ StorageMapping
list of StorageMapping used at registration time