diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2016-12-05 08:48:09 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2016-12-05 08:48:09 +0200 |
commit | 3d7a66aeb49cadc0f4faffa465ef994539629aa9 (patch) | |
tree | 754e4eee1f7612d6470b5ed18e6e616a7806c961 /include | |
parent | e2bd3a059eb8268d156baf59e41909cae1e28297 (diff) | |
download | mailutils-3d7a66aeb49cadc0f4faffa465ef994539629aa9.tar.gz mailutils-3d7a66aeb49cadc0f4faffa465ef994539629aa9.tar.bz2 |
Improve opool
* include/mailutils/opool.h (mu_opool_detach): New proto.
* libmailutils/base/opool.c (mu_opool_bucket): Redo as union
to ensure proper alignment. All uses changed.
(mu_opool_detach): New function.
Diffstat (limited to 'include')
-rw-r--r-- | include/mailutils/opool.h | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/include/mailutils/opool.h b/include/mailutils/opool.h index 63c5a38f2..45fe64f8f 100644 --- a/include/mailutils/opool.h +++ b/include/mailutils/opool.h @@ -79,13 +79,23 @@ size_t mu_opool_copy (mu_opool_t opool, void *buf, size_t size); If PSIZE is not NULL, store the size of the head chunk to *PSIZE. */ void *mu_opool_head (mu_opool_t opool, size_t *psize); -/* Finish building the object. Equivalent to: +/* Finishes the object being constructed. Returns pointer to the object, + and its size in PSIZE (unless it is NULL). + + Equivalent to: mu_opool_coalesce (opool, NULL); p = mu_opool_head (opool, psize); mu_opool_clear (opool); return p; */ void *mu_opool_finish (mu_opool_t opool, size_t *psize); + +/* Similar to mu_opool_finish, but also detaches the created object from the + pool, so that the latter can be destroyed without affecting the object. + The returned pointer should be deallocated with free(3) when no longer + needed. */ +void *mu_opool_detach (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); |