28
28
struct uid_cache_entry {
29
29
uid_t uid ;
30
30
gid_t main_gid ;
31
- int username_offset ;/*arena- allocated */
31
+ int username_offset ;/* allocated in cache_memory_block */
32
32
};
33
33
34
34
struct gid_cache_entry {
35
35
gid_t gid ;
36
36
int uid_count ;
37
- int uids_offset ;/*arena- allocated */
37
+ int uids_offset ;/* allocated in cache_memory_block */
38
38
};
39
39
40
40
static pthread_rwlock_t cache_lock = PTHREAD_RWLOCK_INITIALIZER ;
@@ -47,7 +47,7 @@ static struct gid_cache_entry *gid_cache = NULL;
47
47
static int gid_cache_size = 0 ;
48
48
static int gid_cache_capacity = 0 ;
49
49
50
- static struct arena cache_arena = ARENA_INITIALIZER ;
50
+ static struct memory_block cache_memory_block = MEMORY_BLOCK_INITIALIZER ;
51
51
52
52
static volatile int cache_rebuild_requested = 1 ;
53
53
@@ -67,8 +67,8 @@ static int gid_cache_gid_searchcmp(const void *key, const void *entry);
67
67
68
68
static void rebuild_cache ()
69
69
{
70
- free_arena ( & cache_arena );
71
- init_arena ( & cache_arena ,1024 );
70
+ free_memory_block ( & cache_memory_block );
71
+ init_memory_block ( & cache_memory_block ,1024 );
72
72
rebuild_uid_cache ();
73
73
rebuild_gid_cache ();
74
74
qsort (uid_cache ,uid_cache_size ,sizeof (struct uid_cache_entry ),uid_cache_uid_sortcmp );
@@ -126,7 +126,7 @@ static int rebuild_uid_cache()
126
126
ent -> main_gid = pw -> pw_gid ;
127
127
128
128
username_len = strlen (pw -> pw_name )+ 1 ;
129
- ent -> username_offset = append_to_arena ( & cache_arena ,pw -> pw_name ,username_len );
129
+ ent -> username_offset = append_to_memory_block ( & cache_memory_block ,pw -> pw_name ,username_len );
130
130
}
131
131
132
132
endpwent ();
@@ -168,7 +168,7 @@ static int rebuild_gid_cache()
168
168
ent = & gid_cache [gid_cache_size ++ ];
169
169
ent -> gid = gr -> gr_gid ;
170
170
ent -> uid_count = 0 ;
171
- ent -> uids_offset = cache_arena .size ;
171
+ ent -> uids_offset = cache_memory_block .size ;
172
172
173
173
for (i = 0 ;gr -> gr_mem [i ]!= NULL ;++ i ) {
174
174
uid_ent = (struct uid_cache_entry * )bsearch (
@@ -179,8 +179,8 @@ static int rebuild_gid_cache()
179
179
uid_cache_name_searchcmp
180
180
);
181
181
if (uid_ent != NULL ) {
182
- grow_arena ( & cache_arena ,sizeof (uid_t ));
183
- ((uid_t * )ARENA_GET ( cache_arena ,ent -> uids_offset ))[ent -> uid_count ++ ]= uid_ent -> uid ;
182
+ grow_memory_block ( & cache_memory_block ,sizeof (uid_t ));
183
+ ((uid_t * )MEMORY_BLOCK_GET ( cache_memory_block ,ent -> uids_offset ))[ent -> uid_count ++ ]= uid_ent -> uid ;
184
184
}
185
185
}
186
186
}
@@ -208,15 +208,15 @@ static int uid_cache_name_sortcmp(const void *a, const void *b)
208
208
{
209
209
int name_a_off = ((struct uid_cache_entry * )a )-> username_offset ;
210
210
int name_b_off = ((struct uid_cache_entry * )b )-> username_offset ;
211
- const char * name_a = (const char * )ARENA_GET ( cache_arena ,name_a_off );
212
- const char * name_b = (const char * )ARENA_GET ( cache_arena ,name_b_off );
211
+ const char * name_a = (const char * )MEMORY_BLOCK_GET ( cache_memory_block ,name_a_off );
212
+ const char * name_b = (const char * )MEMORY_BLOCK_GET ( cache_memory_block ,name_b_off );
213
213
return strcmp (name_a ,name_b );
214
214
}
215
215
216
216
static int uid_cache_name_searchcmp (const void * key ,const void * entry )
217
217
{
218
218
int name_off = ((struct uid_cache_entry * )entry )-> username_offset ;
219
- const char * name = (const char * )ARENA_GET ( cache_arena ,name_off );
219
+ const char * name = (const char * )MEMORY_BLOCK_GET ( cache_memory_block ,name_off );
220
220
return strcmp ((const char * )key ,name );
221
221
}
222
222
@@ -368,7 +368,7 @@ int user_belongs_to_group(uid_t uid, gid_t gid)
368
368
369
369
struct gid_cache_entry * gent = gid_cache_lookup (gid );
370
370
if (gent ) {
371
- uids = (uid_t * )ARENA_GET ( cache_arena ,gent -> uids_offset );
371
+ uids = (uid_t * )MEMORY_BLOCK_GET ( cache_memory_block ,gent -> uids_offset );
372
372
for (i = 0 ;i < gent -> uid_count ;++ i ) {
373
373
if (uids [i ]== uid ) {
374
374
ret = 1 ;