diff options
author | hunt <hunt> | 2005-09-14 21:13:55 +0000 |
---|---|---|
committer | hunt <hunt> | 2005-09-14 21:13:55 +0000 |
commit | 89ad3fb09bc48bb77aa1dd16af52720aff51ca68 (patch) | |
tree | e6dac8320b67cb7f86802a8559937c41fd14d5cb /runtime/map.c | |
parent | 0235ca6a116e0f20607e4e8d5bd0547750469d16 (diff) | |
download | systemtap-steved-89ad3fb09bc48bb77aa1dd16af52720aff51ca68.tar.gz systemtap-steved-89ad3fb09bc48bb77aa1dd16af52720aff51ca68.tar.xz systemtap-steved-89ad3fb09bc48bb77aa1dd16af52720aff51ca68.zip |
2005-09-14 Martin Hunt <hunt@redhat.com>
* map.c (_stp_map_clear): New function. CLears a map but
does not free it.
Diffstat (limited to 'runtime/map.c')
-rw-r--r-- | runtime/map.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/runtime/map.c b/runtime/map.c index 179f5098..9d83595d 100644 --- a/runtime/map.c +++ b/runtime/map.c @@ -262,6 +262,35 @@ struct map_node *_stp_map_iter(MAP map, struct map_node *m) return (struct map_node *)m->lnode.next; } +/** Clears all the elements in a map. + * @param map + */ + +void _stp_map_clear(MAP map) +{ + struct map_node *m; + + if (map == NULL) + return; + + map->create = 0; + map->key = NULL; + map->num = 0; + + while (!list_empty(&map->head)) { + m = (struct map_node *)map->head.next; + + /* remove node from old hash list */ + hlist_del_init(&m->hnode); + + /* remove from entry list */ + list_del(&m->lnode); + + /* add to free pool */ + list_add(&m->lnode, &map->pool); + } +} + /** Deletes a map. * Deletes a map, freeing all memory in all elements. Normally done only when the module exits. * @param map |