suricata
|
#include "suricata-common.h"
#include "util-unittest.h"
#include "util-storage.h"
#include "util-debug.h"
Go to the source code of this file.
Data Structures | |
struct | StorageMapping_ |
struct | StorageList_ |
list of StorageMapping used at registration time More... | |
Typedefs | |
typedef struct StorageMapping_ | StorageMapping |
typedef struct StorageList_ | StorageList |
list of StorageMapping used at registration time | |
Functions | |
void | StorageInit (void) |
void | StorageCleanup (void) |
int | StorageRegister (const StorageEnum type, const char *name, const unsigned int size, void *(*Alloc)(unsigned int), void(*Free)(void *)) |
Register new storage. | |
int | StorageFinalize (void) |
unsigned int | StorageGetCnt (StorageEnum type) |
unsigned int | StorageGetSize (StorageEnum type) |
get the size of the void array used to store the pointers | |
void * | StorageGetById (const Storage *storage, const StorageEnum type, const int id) |
get storage for id | |
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) |
void | StorageFreeAll (Storage *storage, StorageEnum type) |
Storage API
Definition in file util-storage.c.
typedef struct StorageList_ StorageList |
list of StorageMapping used at registration time
typedef struct StorageMapping_ StorageMapping |
void * StorageAllocByIdPrealloc | ( | Storage * | storage, |
StorageEnum | type, | ||
int | id | ||
) |
AllocById func for prealloc'd base storage (storage ptrs are part of another memory block)
Definition at line 238 of file util-storage.c.
References StorageMapping_::Alloc, BUG_ON, id, StorageList_::map, Storage::ptr, SCLogDebug, StorageMapping_::size, and type.
Referenced by FlowAllocStorageById(), HostAllocStorageById(), IPPairAllocStorageById(), and ThreadAllocStorageById().
void StorageCleanup | ( | void | ) |
Definition at line 78 of file util-storage.c.
References next, StorageList_::next, SCFree, and STORAGE_MAX.
int StorageFinalize | ( | void | ) |
Definition at line 140 of file util-storage.c.
References StorageMapping_::Alloc, StorageMapping_::Free, StorageList_::id, m, StorageList_::map, StorageMapping_::name, next, StorageList_::next, SCCalloc, SCFree, SCLogDebug, StorageMapping_::size, STORAGE_MAX, StorageMapping_::type, and unlikely.
Referenced by PostConfLoadedSetup(), and RunUnittests().
void StorageFreeAll | ( | Storage * | storage, |
StorageEnum | type | ||
) |
Definition at line 278 of file util-storage.c.
References BUG_ON, StorageMapping_::Free, StorageList_::map, Storage::ptr, and type.
Referenced by FlowFreeStorage(), HostFreeStorage(), IPPairFreeStorage(), LiveDevFreeStorage(), and ThreadFreeStorage().
void StorageFreeById | ( | Storage * | storage, |
StorageEnum | type, | ||
int | id | ||
) |
Definition at line 256 of file util-storage.c.
References BUG_ON, StorageMapping_::Free, id, StorageList_::map, Storage::ptr, SCLogDebug, and type.
Referenced by FlowFreeStorageById(), and ThreadFreeStorageById().
void * StorageGetById | ( | const Storage * | storage, |
const StorageEnum | type, | ||
const int | id | ||
) |
get storage for id
Definition at line 215 of file util-storage.c.
References BUG_ON, id, Storage::ptr, and SCLogDebug.
Referenced by FlowGetStorageById(), HostGetStorageById(), IPPairGetStorageById(), LiveDevGetStorageById(), and ThreadGetStorageById().
unsigned int StorageGetCnt | ( | StorageEnum | type | ) |
Definition at line 199 of file util-storage.c.
References type.
unsigned int StorageGetSize | ( | StorageEnum | type | ) |
get the size of the void array used to store the pointers
size | size in bytes, can return 0 if not storage is needed |
Definition at line 210 of file util-storage.c.
References type.
Referenced by FlowStorageSize(), HostStorageSize(), IPPairStorageSize(), LiveDevStorageSize(), and ThreadStorageSize().
void StorageInit | ( | void | ) |
Definition at line 70 of file util-storage.c.
Referenced by PostConfLoadedSetup(), and RunUnittests().
int StorageRegister | ( | const StorageEnum | type, |
const char * | name, | ||
const unsigned int | size, | ||
void *(*)(unsigned int) | Alloc, | ||
void(*)(void *) | Free | ||
) |
Register new storage.
type | type from StorageEnum |
name | name |
size | size of the per instance storage |
Alloc | alloc function for per instance storage |
Free | free function for per instance storage |
Definition at line 102 of file util-storage.c.
References StorageMapping_::Alloc, StorageMapping_::Free, StorageList_::id, StorageList_::map, name, StorageMapping_::name, StorageList_::next, SCCalloc, SCLogError, StorageMapping_::size, STORAGE_MAX, type, StorageMapping_::type, and unlikely.
Referenced by FlowStorageRegister(), HostStorageRegister(), IPPairStorageRegister(), LiveDevStorageRegister(), and ThreadStorageRegister().
int StorageSetById | ( | Storage * | storage, |
const StorageEnum | type, | ||
const int | id, | ||
void * | ptr | ||
) |
set storage for id
Definition at line 226 of file util-storage.c.
References BUG_ON, id, Storage::ptr, and SCLogDebug.
Referenced by FlowSetStorageById(), HostSetStorageById(), IPPairSetStorageById(), LiveDevSetStorageById(), and ThreadSetStorageById().