From 0d0599f5539fe21a783937c7a529e0b66fb12b99 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 5 Sep 2015 01:30:05 +0200 Subject: destruction of message spools and pools causes stored objects to be deallocated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/libmdsclient/inbound.c | 7 +++++-- src/libmdsclient/inbound.h | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') 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 */ -- cgit v1.2.3-70-g09d2