Commit 6ed28e0a 6ed28e0a60638e6f4d744487c8745cb9fb4aaca7 by Sergey Poznyakoff

(sieve_slist_destroy): Use list_do. It is faster.

1 parent 7c671ef4
...@@ -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
...@@ -231,7 +229,7 @@ _sieve_default_parse_error (void *unused, const char *filename, int lineno, ...@@ -231,7 +229,7 @@ _sieve_default_parse_error (void *unused, const char *filename, int lineno,
231 const char *fmt, va_list ap) 229 const char *fmt, va_list ap)
232 { 230 {
233 if (filename) 231 if (filename)
234 fprintf (stderr, "%s:%d: ", filename, lineno); 232 fprintf (stderr, "%s:%d: ", filename, lineno);
235 vfprintf (stderr, fmt, ap); 233 vfprintf (stderr, fmt, ap);
236 fprintf (stderr, "\n"); 234 fprintf (stderr, "\n");
237 return 0; 235 return 0;
......