summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2016-10-30 10:50:07 +0200
committerSergey Poznyakoff <gray@gnu.org>2016-10-30 10:50:07 +0200
commitb54540cbbc95069b6d073246a575683170920275 (patch)
treebf7d188d6ae5fa434be6a71b9c415b0d163b8aab /include
parentc6848f52257191abb36b694be61ce333a8992b4b (diff)
downloadmailutils-b54540cbbc95069b6d073246a575683170920275.tar.gz
mailutils-b54540cbbc95069b6d073246a575683170920275.tar.bz2
Improve opool API
* configure.ac: Version 2.99.993 * NEWS: Update. * include/mailutils/opool.h (MU_OPOOL_DEFAULT) (MU_OPOOL_ENOMEMABRT): New defines. (mu_opool_create): Change meaning of the 2nd argument. All uses updated. (mu_opool_free, mu_opool_dup): New proto. * libmailutils/base/opool.c (_mu_opool) <memerr>: Replace with flags. <head,tail,free>: Rename. (mu_opool_free, mu_opool_dup): New functions. (mu_opool_head): Bugfix.
Diffstat (limited to 'include')
-rw-r--r--include/mailutils/opool.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/include/mailutils/opool.h b/include/mailutils/opool.h
index bc68e4aab..63c5a38f2 100644
--- a/include/mailutils/opool.h
+++ b/include/mailutils/opool.h
@@ -24,10 +24,12 @@
# define MU_OPOOL_BUCKET_SIZE 1024
#endif
-/* Create an object pool. If MEMERR is not 0, any operation of the
- resulting pool (including mu_opool_create itself) will abort on
- not enough memory condition, using mu_alloc_die. */
-int mu_opool_create (mu_opool_t *pret, int memerr);
+/* Flags for mu_opool_create call: */
+#define MU_OPOOL_DEFAULT 0
+#define MU_OPOOL_ENOMEMABRT 0x01 /* Abort on ENOMEM error */
+
+/* Create an object pool. */
+int mu_opool_create (mu_opool_t *pret, int flags);
int mu_opool_set_bucket_size (mu_opool_t opool, size_t size);
int mu_opool_get_bucket_size (mu_opool_t opool, size_t *psize);
@@ -39,6 +41,10 @@ int mu_opool_union (mu_opool_t *dst, mu_opool_t *src);
begin a new object. */
void mu_opool_clear (mu_opool_t opool);
+/* Free object OBJ from the pool. If OBJ is NULL, free all created objects,
+ including the one being built */
+void mu_opool_free (mu_opool_t pool, void *obj);
+
/* Destroy the pool, reclaim any memory associated with it. */
void mu_opool_destroy (mu_opool_t *popool);
@@ -80,6 +86,10 @@ void *mu_opool_head (mu_opool_t opool, size_t *psize);
return p; */
void *mu_opool_finish (mu_opool_t opool, size_t *psize);
+/* Append SIZE bytes from DATA to the pool and return the pointer to the
+ created object. */
+void *mu_opool_dup (mu_opool_t pool, void const *data, size_t size);
+
int mu_opool_get_iterator (mu_opool_t opool, mu_iterator_t *piterator);
#endif

Return to:

Send suggestions and report system problems to the System administrator.