git.asbjorn.biz
/
swftools.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
e560bd2
)
new function dict_destroy_shallow
author
Matthias Kramm
<kramm@quiss.org>
Fri, 16 Jan 2009 01:55:32 +0000
(17:55 -0800)
committer
Matthias Kramm
<kramm@quiss.org>
Fri, 16 Jan 2009 01:55:32 +0000
(17:55 -0800)
lib/q.c
patch
|
blob
|
history
lib/q.h
patch
|
blob
|
history
diff --git
a/lib/q.c
b/lib/q.c
index
9bdcdf0
..
512e3d0
100644
(file)
--- a/
lib/q.c
+++ b/
lib/q.c
@@
-932,16
+932,18
@@
void dict_foreach_value(dict_t*h, void (*runFunction)(void*))
}
}
}
}
-void dict_free_all(dict_t*h, void (*freeFunction)(void*))
+void dict_free_all(dict_t*h, char free_keys, void (*free_data_function)(void*))
{
int t;
for(t=0;t<h->hashsize;t++) {
dictentry_t*e = h->slots[t];
while(e) {
dictentry_t*next = e->next;
{
int t;
for(t=0;t<h->hashsize;t++) {
dictentry_t*e = h->slots[t];
while(e) {
dictentry_t*next = e->next;
- h->key_type->free(e->key);
- if(freeFunction) {
- freeFunction(e->data);
+ if(free_keys) {
+ h->key_type->free(e->key);
+ }
+ if(free_data_function) {
+ free_data_function(e->data);
}
memset(e, 0, sizeof(dictentry_t));
rfx_free(e);
}
memset(e, 0, sizeof(dictentry_t));
rfx_free(e);
@@
-953,9
+955,20
@@
void dict_free_all(dict_t*h, void (*freeFunction)(void*))
memset(h, 0, sizeof(dict_t));
}
memset(h, 0, sizeof(dict_t));
}
+void dict_clear_shallow(dict_t*h)
+{
+ dict_free_all(h, 0, 0);
+}
+
void dict_clear(dict_t*h)
{
void dict_clear(dict_t*h)
{
- dict_free_all(h, 0);
+ dict_free_all(h, 1, 0);
+}
+
+void dict_destroy_shallow(dict_t*dict)
+{
+ dict_clear_shallow(dict);
+ rfx_free(dict);
}
void dict_destroy(dict_t*dict)
}
void dict_destroy(dict_t*dict)
@@
-1010,7
+1023,7
@@
void map_dump(map_t*map, FILE*fi, const char*prefix)
void map_clear(map_t*map)
{
map_internal_t*m = (map_internal_t*)map->internal;
void map_clear(map_t*map)
{
map_internal_t*m = (map_internal_t*)map->internal;
- dict_free_all(&m->d, freestring);
+ dict_free_all(&m->d, 1, freestring);
rfx_free(m);
}
void map_destroy(map_t*map)
rfx_free(m);
}
void map_destroy(map_t*map)
diff --git
a/lib/q.h
b/lib/q.h
index
6eec83c
..
b90b57a
100644
(file)
--- a/
lib/q.h
+++ b/
lib/q.h
@@
-178,8
+178,9
@@
dict_t*dict_clone(dict_t*);
void dict_foreach_keyvalue(dict_t*h, void (*runFunction)(void*data, const void*key, void*val), void*data);
void dict_foreach_value(dict_t*h, void (*runFunction)(void*));
void dict_foreach_keyvalue(dict_t*h, void (*runFunction)(void*data, const void*key, void*val), void*data);
void dict_foreach_value(dict_t*h, void (*runFunction)(void*));
-void dict_free_all(dict_t*h, void (*freeFunction)(void*));
+void dict_free_all(dict_t*h, char free_keys, void (*free_data_function)(void*));
void dict_clear(dict_t*h);
void dict_clear(dict_t*h);
+void dict_destroy_shallow(dict_t*dict);
void dict_destroy(dict_t*dict);
void map_init(map_t*map);
void dict_destroy(dict_t*dict);
void map_init(map_t*map);