Go to the documentation of this file.
35 void *(*Alloc)(
unsigned int);
48 static int storage_registration_closed = 0;
70 memset(&storage_max_id, 0x00,
sizeof(storage_max_id));
73 storage_registration_closed = 0;
81 if (storage_map[i] != NULL) {
83 storage_map[i] = NULL;
102 if (storage_registration_closed)
106 size == 0 || (size !=
sizeof(
void *) && Alloc == NULL) || Free == NULL)
113 "name \"%s\" already registered",
114 StoragePrintType(
type), name);
131 entry->
id = storage_max_id[
type]++;
132 entry->
next = storage_list;
133 storage_list = entry;
143 storage_registration_closed = 1;
146 if (storage_max_id[i] > 0)
153 if (
unlikely(storage_map == NULL)) {
158 if (storage_max_id[i] > 0) {
160 if (storage_map[i] == NULL)
167 if (storage_map[entry->
map.
type] != NULL) {
183 if (storage_map[i] == NULL)
187 for (j = 0; j < storage_max_id[i]; j++) {
189 SCLogDebug(
"type \"%s\" name \"%s\" size \"%"PRIuMAX
"\"",
190 StoragePrintType(
m->type),
m->name, (uintmax_t)
m->size);
199 return storage_max_id[
type];
210 return storage_max_id[
type] *
sizeof(
void *);
216 BUG_ON(!storage_registration_closed);
221 return storage[
id].
ptr;
227 BUG_ON(!storage_registration_closed);
232 storage[
id].
ptr = ptr;
239 BUG_ON(!storage_registration_closed);
244 if (storage[
id].ptr == NULL &&
map->
Alloc != NULL) {
246 if (storage[
id].ptr == NULL) {
251 return storage[
id].
ptr;
257 BUG_ON(!storage_registration_closed);
260 if (storage_map == NULL)
268 if (store[
id].ptr != NULL) {
271 store[
id].
ptr = NULL;
281 BUG_ON(!storage_registration_closed);
284 if (storage_map == NULL)
290 for (i = 0; i < storage_max_id[
type]; i++) {
291 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