diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-09-05 01:30:05 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-09-05 01:30:05 +0200 |
commit | 0d0599f5539fe21a783937c7a529e0b66fb12b99 (patch) | |
tree | f80ab24008bd33de96e44da1bb93c0715d0fb9f1 | |
parent | vrindex (diff) | |
download | mds-0d0599f5539fe21a783937c7a529e0b66fb12b99.tar.gz mds-0d0599f5539fe21a783937c7a529e0b66fb12b99.tar.bz2 mds-0d0599f5539fe21a783937c7a529e0b66fb12b99.tar.xz |
destruction of message spools and pools causes stored objects to be deallocated
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r-- | src/libmdsclient/inbound.c | 7 | ||||
-rw-r--r-- | src/libmdsclient/inbound.h | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/src/libmdsclient/inbound.c b/src/libmdsclient/inbound.c index e2831a6..9f0254a 100644 --- a/src/libmdsclient/inbound.c +++ b/src/libmdsclient/inbound.c @@ -60,8 +60,7 @@ int libmds_message_initialise(libmds_message_t* restrict this) /** - * Release all resources in a message, should - * be done even if initialisation fails + * Release all resources in a message * * @param this The message */ @@ -577,6 +576,8 @@ void libmds_mspool_destroy(libmds_mspool_t* restrict this) { if (this->messages == NULL) return; + while (this->tail < this->head) + free(this->messages[this->tail++]); sem_destroy(&(this->lock)); sem_destroy(&(this->semaphore)); sem_destroy(&(this->wait_semaphore)); @@ -776,6 +777,8 @@ void libmds_mpool_destroy(libmds_mpool_t* restrict this) { if (this->messages == NULL) return; + while (this->tip--) + free(this->messages[this->tip]); sem_destroy(&(this->lock)); free(this->messages); this->messages = NULL; diff --git a/src/libmdsclient/inbound.h b/src/libmdsclient/inbound.h index 197c41b..6080729 100644 --- a/src/libmdsclient/inbound.h +++ b/src/libmdsclient/inbound.h @@ -219,8 +219,7 @@ __attribute__((nonnull, warn_unused_result)) int libmds_message_initialise(libmds_message_t* restrict this); /** - * Release all resources in a message, should - * be done even if initialisation fails + * Release all resources in a message * * @param this The message */ |