|
|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
/* Copyright (C) 2018 Open Information Security Foundation
|
|
|
|
|
/* Copyright (C) 2018-2021 Open Information Security Foundation
|
|
|
|
|
*
|
|
|
|
|
* You can copy, redistribute or modify this Program under the terms of
|
|
|
|
|
* the GNU General Public License version 2 as published by the Free
|
|
|
|
|
@ -56,8 +56,12 @@ unsigned int LiveDevStorageSize(void)
|
|
|
|
|
* It has to be called once during the init of the sub system
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int LiveDevStorageRegister(const char *name, const unsigned int size, void *(*Alloc)(unsigned int), void (*Free)(void *)) {
|
|
|
|
|
return StorageRegister(STORAGE_DEVICE, name, size, Alloc, Free);
|
|
|
|
|
LiveDevStorageId LiveDevStorageRegister(const char *name, const unsigned int size,
|
|
|
|
|
void *(*Alloc)(unsigned int), void (*Free)(void *))
|
|
|
|
|
{
|
|
|
|
|
int id = StorageRegister(STORAGE_DEVICE, name, size, Alloc, Free);
|
|
|
|
|
LiveDevStorageId ldsi = { .id = id };
|
|
|
|
|
return ldsi;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -68,9 +72,9 @@ int LiveDevStorageRegister(const char *name, const unsigned int size, void *(*Al
|
|
|
|
|
* \param ptr pointer to the data to store
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int LiveDevSetStorageById(LiveDevice *d, int id, void *ptr)
|
|
|
|
|
int LiveDevSetStorageById(LiveDevice *d, LiveDevStorageId id, void *ptr)
|
|
|
|
|
{
|
|
|
|
|
return StorageSetById((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id, ptr);
|
|
|
|
|
return StorageSetById((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id.id, ptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -81,9 +85,9 @@ int LiveDevSetStorageById(LiveDevice *d, int id, void *ptr)
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void *LiveDevGetStorageById(LiveDevice *d, int id)
|
|
|
|
|
void *LiveDevGetStorageById(LiveDevice *d, LiveDevStorageId id)
|
|
|
|
|
{
|
|
|
|
|
return StorageGetById((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id);
|
|
|
|
|
return StorageGetById((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -92,14 +96,15 @@ void *LiveDevGetStorageById(LiveDevice *d, int id)
|
|
|
|
|
|
|
|
|
|
/* Start of "private" function */
|
|
|
|
|
|
|
|
|
|
void *LiveDevAllocStorageById(LiveDevice *d, int id)
|
|
|
|
|
void *LiveDevAllocStorageById(LiveDevice *d, LiveDevStorageId id)
|
|
|
|
|
{
|
|
|
|
|
return StorageAllocByIdPrealloc((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id);
|
|
|
|
|
return StorageAllocByIdPrealloc(
|
|
|
|
|
(Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LiveDevFreeStorageById(LiveDevice *d, int id)
|
|
|
|
|
void LiveDevFreeStorageById(LiveDevice *d, LiveDevStorageId id)
|
|
|
|
|
{
|
|
|
|
|
StorageFreeById((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id);
|
|
|
|
|
StorageFreeById((Storage *)((void *)d + sizeof(LiveDevice)), STORAGE_DEVICE, id.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LiveDevFreeStorage(LiveDevice *d)
|
|
|
|
|
|