summaryrefslogtreecommitdiff
path: root/libsieve
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2002-11-15 14:43:03 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2002-11-15 14:43:03 +0000
commit516006adffa6bf5cad7625a4eaf6edda3adb2d44 (patch)
treee1cf0f50ea66ee534e8e52f5ed95b48c99abc0e9 /libsieve
parentd60f602a61db3fd954fdf3ba855b432a44a4d222 (diff)
downloadmailutils-516006adffa6bf5cad7625a4eaf6edda3adb2d44.tar.gz
mailutils-516006adffa6bf5cad7625a4eaf6edda3adb2d44.tar.bz2
(sieve_machine_init): Fixed return value.
(sieve_machine_add_destructor,sieve_machine_destroy): New functions.
Diffstat (limited to 'libsieve')
-rw-r--r--libsieve/sieve.y43
1 files changed, 42 insertions, 1 deletions
diff --git a/libsieve/sieve.y b/libsieve/sieve.y
index d280f4f24..c4919b93a 100644
--- a/libsieve/sieve.y
+++ b/libsieve/sieve.y
@@ -349,7 +349,7 @@ sieve_machine_init (sieve_machine_t *pmach, void *data)
if (rc)
{
free (mach);
- return NULL;
+ return 1;
}
list_append (mach->memory_pool, mach);
@@ -404,6 +404,47 @@ sieve_get_ticket (sieve_machine_t mach)
return mach->ticket;
}
+struct sieve_destr_record
+{
+ sieve_destructor_t destr;
+ void *ptr;
+};
+
+int
+sieve_machine_add_destructor (sieve_machine_t mach, sieve_destructor_t destr,
+ void *ptr)
+{
+ struct sieve_destr_record *p;
+
+ if (!mach->destr_list && list_create (&mach->destr_list))
+ return 1;
+ p = sieve_palloc (&mach->memory_pool, sizeof (*p));
+ if (!p)
+ return 1;
+ p->destr = destr;
+ p->ptr = ptr;
+ return list_append (mach->memory_pool, p);
+}
+
+static int
+_run_destructor (void *data, void *unused)
+{
+ struct sieve_destr_record *p = data;
+ p->destr (p->ptr);
+ return 0;
+}
+
+void
+sieve_machine_destroy (sieve_machine_t *pmach)
+{
+ sieve_machine_t mach = *pmach;
+ list_do (mach->destr_list, _run_destructor, NULL);
+ list_destroy (&mach->destr_list);
+ sieve_slist_destroy (&mach->memory_pool);
+ free (mach);
+ *pmach = NULL;
+}
+
/* FIXME: When posix thread support is added, sieve_machine_begin() should
acquire the global mutex, locking the current compilation session, and
sieve_machine_finish() should release it */

Return to:

Send suggestions and report system problems to the System administrator.