(sieve_slist_destroy): Use list_do. It is faster.
Showing
1 changed file
with
9 additions
and
11 deletions
... | @@ -100,21 +100,19 @@ sieve_pfree (list_t *pool, void *ptr) | ... | @@ -100,21 +100,19 @@ sieve_pfree (list_t *pool, void *ptr) |
100 | free (ptr); | 100 | free (ptr); |
101 | } | 101 | } |
102 | 102 | ||
103 | static int | ||
104 | _destroy_item (void *item, void *data) | ||
105 | { | ||
106 | free (item); | ||
107 | return 0; | ||
108 | } | ||
109 | |||
103 | void | 110 | void |
104 | sieve_slist_destroy (list_t *plist) | 111 | sieve_slist_destroy (list_t *plist) |
105 | { | 112 | { |
106 | iterator_t itr; | 113 | if (!plist) |
107 | |||
108 | if (!plist || iterator_create (&itr, *plist)) | ||
109 | return; | 114 | return; |
110 | 115 | list_do (*plist, _destroy_item, NULL); | |
111 | for (iterator_first (itr); !iterator_is_done (itr); iterator_next (itr)) | ||
112 | { | ||
113 | char *s; | ||
114 | iterator_current (itr, (void **)&s); | ||
115 | free (s); | ||
116 | } | ||
117 | iterator_destroy (&itr); | ||
118 | list_destroy (plist); | 116 | list_destroy (plist); |
119 | } | 117 | } |
120 | 118 | ... | ... |
-
Please register or sign in to post a comment