diff options
Diffstat (limited to 'collections/double_ended_queue.c')
-rw-r--r-- | collections/double_ended_queue.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/collections/double_ended_queue.c b/collections/double_ended_queue.c index 956e362..7938307 100644 --- a/collections/double_ended_queue.c +++ b/collections/double_ended_queue.c @@ -184,6 +184,9 @@ deq *root; return root->base[root->end]; } +/* Note: Elements are not freed + * deq_clear should be called before if they are no longer needed. + */ void deq_free(root) deq *root; { @@ -193,6 +196,17 @@ deq *root; free(root); } +void deq_clear(root) +deq *root; +{ + int i, size; + + size = deq_size(root); + for (i = 0; i < size; i++) { + free(deq_index(root, i)); + } +} + void deq_print(root, to_string) deq *root; char* to_string(void*); |