summaryrefslogtreecommitdiff
path: root/libmailutils/base/opool.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-12-06 15:32:20 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-12-06 15:47:19 +0200
commitdf608ed0cfb5f0db57d1ff97eb208ceb46f06e17 (patch)
tree87536d81395c41d8720dd846d18665108559773d /libmailutils/base/opool.c
parentf8a0fd0fdb20fdb607343d932f19e650dfd8f1d2 (diff)
downloadmailutils-df608ed0cfb5f0db57d1ff97eb208ceb46f06e17.tar.gz
mailutils-df608ed0cfb5f0db57d1ff97eb208ceb46f06e17.tar.bz2
New API for converting globbing patterns to extended POSIX regex
* include/mailutils/opool.h (mu_nonlocal_jmp_t): New type. (mu_opool_setjmp,mu_opool_clrjmp): New functions. (mu_opool_setup_nonlocal_jump): New macro. * libmailutils/base/opool.c (_mu_opool)<jmp>: New field. (alloc_bucket): Do a non-local jump on out of memory condition, if jmp is not NULL. (mu_opool_setjmp,mu_opool_clrjmp): New functions. * libmailutils/base/glob.c: New file. * libmailutils/base/Makefile.am: Add glob.c * include/mailutils/glob.h: New file. * include/mailutils/mailutils.h: Include glob.h * libmailutils/tests/globtest.c: New file. * libmailutils/tests/globtest.at: New test. * libmailutils/tests/Makefile.am: Add new files. * libmailutils/tests/testsuite.at: Include new test.
Diffstat (limited to 'libmailutils/base/opool.c')
-rw-r--r--libmailutils/base/opool.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libmailutils/base/opool.c b/libmailutils/base/opool.c
index d6628dda0..4dedd7ca7 100644
--- a/libmailutils/base/opool.c
+++ b/libmailutils/base/opool.c
@@ -53,6 +53,7 @@ struct _mu_opool
int flags; /* Flag bits */
size_t bucket_size; /* Default bucket size */
size_t itr_count; /* Number of iterators created for this pool */
+ mu_nonlocal_jmp_t *jmp; /* Buffer for non-local exit */
union mu_opool_bucket *bkt_head, *bkt_tail;
union mu_opool_bucket *bkt_fini; /* List of finished objects */
};
@@ -65,6 +66,8 @@ alloc_bucket (struct _mu_opool *opool, size_t size)
{
if (opool->flags & MU_OPOOL_ENOMEMABRT)
mu_alloc_die ();
+ if (opool->jmp)
+ longjmp (opool->jmp->buf, ENOMEM);
}
else
{
@@ -122,10 +125,30 @@ mu_opool_create (mu_opool_t *pret, int flags)
x->bucket_size = MU_OPOOL_BUCKET_SIZE;
x->itr_count = 0;
x->bkt_head = x->bkt_tail = x->bkt_fini = NULL;
+ x->jmp = NULL;
*pret = x;
return 0;
}
+void
+mu_opool_setjmp (mu_opool_t opool, mu_nonlocal_jmp_t *jmp)
+{
+ if (jmp)
+ {
+ jmp->next = opool->jmp;
+ opool->jmp = jmp;
+ }
+ else
+ mu_opool_clrjmp (opool);
+}
+
+void
+mu_opool_clrjmp (mu_opool_t opool)
+{
+ if (opool->jmp)
+ opool->jmp = opool->jmp->next;
+}
+
int
mu_opool_set_bucket_size (mu_opool_t opool, size_t size)
{

Return to:

Send suggestions and report system problems to the System administrator.