summaryrefslogtreecommitdiffabout
path: root/include
authorSergey Poznyakoff <gray@gnu.org.ua>2016-08-25 13:06:58 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2016-08-25 13:06:58 (GMT)
commitc2f02c56a38a3e6d50b8ca2081db9d2de658b8ed (patch) (side-by-side diff)
treea6c80fd81a6b5aad899d8fb0e3e41ece650eed9b /include
parent102d1b9c1a94548dfa0c498845c77933db6a7738 (diff)
downloadgrecs-c2f02c56a38a3e6d50b8ca2081db9d2de658b8ed.tar.gz
grecs-c2f02c56a38a3e6d50b8ca2081db9d2de658b8ed.tar.bz2
symtabs: allow to modify the list during iteration over it.
* include/grecs/list.h (grecs_list_remove): New proto. * include/grecs/symtab.h (grecs_symtab_count_entries): Rename to grecs_symtab_count. * src/list.c (grecs_list_remove): New function. (grecs_list_remove_tail, grecs_list_clear) (grecs_list_locate,grecs_list_index): Treat NULL list as empty list. * src/symtab.c: Defer table modifications during iteration (symtab_defer_type): New enum. (grecs_symtab)<elcount,itr_level,defer_list>: New members. (symtab_defer_op): New static function. (grecs_symtab_remove): When called during iteration, add the entry to the defer_del deferment list, unless it is already in defer_add, in which case remove it from there. Update elcount. (grecs_symtab_lookup_or_install): Defer addition when iterating. Update elcount. (grecs_symtab_clear): Reset elcount to 0. (grecs_symtab_create): Initialize elcount. (grecs_symtab_foreach): Process deferred modifications.
Diffstat (limited to 'include') (more/less context) (ignore whitespace changes)
-rw-r--r--include/grecs/list.h1
-rw-r--r--include/grecs/symtab.h6
2 files changed, 4 insertions, 3 deletions
diff --git a/include/grecs/list.h b/include/grecs/list.h
index a5840db..f950176 100644
--- a/include/grecs/list.h
+++ b/include/grecs/list.h
@@ -41,6 +41,7 @@ void *grecs_list_locate(grecs_list_ptr_t, void *);
void *grecs_list_index(grecs_list_ptr_t, size_t);
void *grecs_list_remove_tail(grecs_list_ptr_t);
void grecs_list_remove_entry(grecs_list_ptr_t, grecs_list_entry_ptr_t);
+int grecs_list_remove(struct grecs_list *lp, void *data);
void grecs_list_clear(grecs_list_ptr_t);
void grecs_list_free(grecs_list_ptr_t);
void grecs_list_add(grecs_list_ptr_t, grecs_list_ptr_t);
diff --git a/include/grecs/symtab.h b/include/grecs/symtab.h
index 3008b17..e079ea5 100644
--- a/include/grecs/symtab.h
+++ b/include/grecs/symtab.h
@@ -42,10 +42,10 @@ grecs_symtab_ptr_t grecs_symtab_create_default(size_t elsize);
void grecs_symtab_free(grecs_symtab_ptr_t pst);
int grecs_symtab_remove(grecs_symtab_ptr_t st, void *elt);
int grecs_symtab_replace(grecs_symtab_ptr_t st, void *ent, void **old_ent);
-int grecs_symtab_enumerate(grecs_symtab_ptr_t st,
- grecs_symtab_enumerator_t fun, void *data);
+int grecs_symtab_foreach(grecs_symtab_ptr_t st,
+ grecs_symtab_enumerator_t fun, void *data);
-size_t grecs_symtab_count_entries(grecs_symtab_ptr_t st);
+size_t grecs_symtab_count(grecs_symtab_ptr_t st);
unsigned grecs_hash_string(const char *name, unsigned long hashsize);
unsigned grecs_hash_string_ci(const char *name, unsigned long hashsize);

Return to:

Send suggestions and report system problems to the System administrator.