Skip to content

Commit d1d319d

Browse files
committed
map: rework persistent storage
1 parent a45544e commit d1d319d

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

map.c

+18-13
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,26 @@
3232

3333
#include "mem/mem.h"
3434
#include "mem/shm_mem.h"
35-
36-
#define avl_malloc(dest,size,flags) do \
37-
{ \
38-
if(flags & AVLMAP_SHARED) \
39-
(dest) = shm_malloc(size); \
40-
else \
41-
(dest) = pkg_malloc(size); \
35+
#include "mem/rpm_mem.h"
36+
37+
#define avl_malloc(dest,size,flags) do \
38+
{ \
39+
if(flags & AVLMAP_SHARED) \
40+
(dest) = shm_malloc(size); \
41+
else if (flags & AVLMAP_PERSISTENT) \
42+
(dest) = rpm_malloc(size); \
43+
else \
44+
(dest) = pkg_malloc(size); \
4245
} while(0)
4346

44-
#define avl_free(dest,flags) do \
45-
{ \
46-
if(flags & AVLMAP_SHARED) \
47-
shm_free(dest); \
48-
else \
49-
pkg_free(dest); \
47+
#define avl_free(dest,flags) do \
48+
{ \
49+
if(flags & AVLMAP_SHARED) \
50+
shm_free(dest); \
51+
else if (flags & AVLMAP_PERSISTENT) \
52+
rpm_free(dest); \
53+
else \
54+
pkg_free(dest); \
5055
} while(0)
5156

5257

map.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ enum map_flags
4141
{
4242
AVLMAP_SHARED = 1, /* determines if the map is to be allocated in
4343
shared or private memory */
44-
AVLMAP_NO_DUPLICATE = 2 /* determines if the map will duplicate added keys*/
44+
AVLMAP_NO_DUPLICATE = 2, /* determines if the map will duplicate added keys*/
45+
AVLMAP_PERSISTENT = 4, /* determines if the map will be stored in
46+
persistent memory */
4547

4648
};
4749

@@ -98,6 +100,7 @@ typedef int (* process_each_func )(void * param, str key, void * value);
98100
*
99101
* AVLMAP_SHARED -> flag for shared memory
100102
* AVLMAP_NO_DUPLICATE -> flag for key duplication
103+
* AVLMAP_PERSISTENT -> flag for persistent shared memory
101104
*
102105
*/
103106

0 commit comments

Comments
 (0)