Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd4a531b

Browse files
committed
Internal renames.
1 parent4465f0e commitd4a531b

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

‎src/misc.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ int parse_byte_count(const char *str, double *result)
170170
return1;
171171
}
172172

173-
voidinit_arena(structarena*a,intinitial_capacity)
173+
voidinit_memory_block(structmemory_block*a,intinitial_capacity)
174174
{
175175
a->size=0;
176176
a->capacity=initial_capacity;
@@ -181,7 +181,7 @@ void init_arena(struct arena *a, int initial_capacity)
181181
}
182182
}
183183

184-
voidgrow_arena(structarena*a,intamount)
184+
voidgrow_memory_block(structmemory_block*a,intamount)
185185
{
186186
intnew_cap;
187187

@@ -198,16 +198,16 @@ void grow_arena(struct arena *a, int amount)
198198
}
199199
}
200200

201-
intappend_to_arena(structarena*a,void*src,intsrc_size)
201+
intappend_to_memory_block(structmemory_block*a,void*src,intsrc_size)
202202
{
203203
intdest=a->size;
204-
grow_arena(a,src_size);
204+
grow_memory_block(a,src_size);
205205
memcpy(&a->ptr[dest],src,src_size);
206206
returndest;
207207
}
208208

209-
voidfree_arena(structarena*a)
209+
voidfree_memory_block(structmemory_block*a)
210210
{
211211
free(a->ptr);
212-
init_arena(a,0);
212+
init_memory_block(a,0);
213213
}

‎src/misc.h‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,21 @@ void grow_array_impl(void **array, int *capacity, int member_size);
5858
/* Returns 1 on success, 0 on syntax error. */
5959
intparse_byte_count(constchar*str,double*result);
6060

61-
/*Simple arenaallocationfor when it'sconvenientto
62-
grow multiple timesanddeallocate all at once. */
63-
structarena {
61+
/*Anallocationof contiguous memory withconvenientfunctions for
62+
growing itandappending to it. */
63+
structmemory_block {
6464
char*ptr;
6565
intsize;
6666
intcapacity;
6767
};
6868

69-
#defineARENA_INITIALIZER { NULL, 0, 0 }
69+
#defineMEMORY_BLOCK_INITIALIZER { NULL, 0, 0 }
7070

71-
voidinit_arena(structarena*a,intinitial_capacity);
72-
voidgrow_arena(structarena*a,intamount);
73-
intappend_to_arena(structarena*a,void*src,intsrc_size);
74-
voidfree_arena(structarena*a);
71+
voidinit_memory_block(structmemory_block*a,intinitial_capacity);
72+
voidgrow_memory_block(structmemory_block*a,intamount);
73+
intappend_to_memory_block(structmemory_block*a,void*src,intsrc_size);
74+
voidfree_memory_block(structmemory_block*a);
7575

76-
#defineARENA_GET(a,offset) (&(a).ptr[(offset)])
76+
#defineMEMORY_BLOCK_GET(a,offset) (&(a).ptr[(offset)])
7777

7878
#endif

‎src/userinfo.c‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
structuid_cache_entry {
2929
uid_tuid;
3030
gid_tmain_gid;
31-
intusername_offset;/*arena-allocated */
31+
intusername_offset;/* allocated in cache_memory_block */
3232
};
3333

3434
structgid_cache_entry {
3535
gid_tgid;
3636
intuid_count;
37-
intuids_offset;/*arena-allocated */
37+
intuids_offset;/* allocated in cache_memory_block */
3838
};
3939

4040
staticpthread_rwlock_tcache_lock=PTHREAD_RWLOCK_INITIALIZER;
@@ -47,7 +47,7 @@ static struct gid_cache_entry *gid_cache = NULL;
4747
staticintgid_cache_size=0;
4848
staticintgid_cache_capacity=0;
4949

50-
staticstructarenacache_arena=ARENA_INITIALIZER;
50+
staticstructmemory_blockcache_memory_block=MEMORY_BLOCK_INITIALIZER;
5151

5252
staticvolatileintcache_rebuild_requested=1;
5353

@@ -67,8 +67,8 @@ static int gid_cache_gid_searchcmp(const void *key, const void *entry);
6767

6868
staticvoidrebuild_cache()
6969
{
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);
7272
rebuild_uid_cache();
7373
rebuild_gid_cache();
7474
qsort(uid_cache,uid_cache_size,sizeof(structuid_cache_entry),uid_cache_uid_sortcmp);
@@ -126,7 +126,7 @@ static int rebuild_uid_cache()
126126
ent->main_gid=pw->pw_gid;
127127

128128
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);
130130
}
131131

132132
endpwent();
@@ -168,7 +168,7 @@ static int rebuild_gid_cache()
168168
ent=&gid_cache[gid_cache_size++];
169169
ent->gid=gr->gr_gid;
170170
ent->uid_count=0;
171-
ent->uids_offset=cache_arena.size;
171+
ent->uids_offset=cache_memory_block.size;
172172

173173
for (i=0;gr->gr_mem[i]!=NULL;++i) {
174174
uid_ent= (structuid_cache_entry*)bsearch(
@@ -179,8 +179,8 @@ static int rebuild_gid_cache()
179179
uid_cache_name_searchcmp
180180
);
181181
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;
184184
}
185185
}
186186
}
@@ -208,15 +208,15 @@ static int uid_cache_name_sortcmp(const void *a, const void *b)
208208
{
209209
intname_a_off= ((structuid_cache_entry*)a)->username_offset;
210210
intname_b_off= ((structuid_cache_entry*)b)->username_offset;
211-
constchar*name_a= (constchar*)ARENA_GET(cache_arena,name_a_off);
212-
constchar*name_b= (constchar*)ARENA_GET(cache_arena,name_b_off);
211+
constchar*name_a= (constchar*)MEMORY_BLOCK_GET(cache_memory_block,name_a_off);
212+
constchar*name_b= (constchar*)MEMORY_BLOCK_GET(cache_memory_block,name_b_off);
213213
returnstrcmp(name_a,name_b);
214214
}
215215

216216
staticintuid_cache_name_searchcmp(constvoid*key,constvoid*entry)
217217
{
218218
intname_off= ((structuid_cache_entry*)entry)->username_offset;
219-
constchar*name= (constchar*)ARENA_GET(cache_arena,name_off);
219+
constchar*name= (constchar*)MEMORY_BLOCK_GET(cache_memory_block,name_off);
220220
returnstrcmp((constchar*)key,name);
221221
}
222222

@@ -368,7 +368,7 @@ int user_belongs_to_group(uid_t uid, gid_t gid)
368368

369369
structgid_cache_entry*gent=gid_cache_lookup(gid);
370370
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);
372372
for (i=0;i<gent->uid_count;++i) {
373373
if (uids[i]==uid) {
374374
ret=1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp