[PATCH] MAMA: Cleanup publisher topic map on dqPublisherManager destroy.


Lee Skillen <lskillen@...>
 

Fixed memory leak when calling dqPublisherManager_destroy() - The
contents of the publisher topic map are now freed inline with the
publisher map itself being destroyed.

Signed-off-by: Lee Skillen <lskillen@vulcanft.com>
---
mama/c_cpp/src/c/dqpublishermanager.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/mama/c_cpp/src/c/dqpublishermanager.c b/mama/c_cpp/src/c/dqpublishermanager.c
index beb3a92..691973b 100644
--- a/mama/c_cpp/src/c/dqpublishermanager.c
+++ b/mama/c_cpp/src/c/dqpublishermanager.c
@@ -62,6 +62,18 @@ typedef struct mamaDQPublisherManagerImpl_

} mamaDQPublisherManagerImpl;

+static
+void cleanupPublisherMap (
+ wtable_t t,
+ void* data,
+ const char* key,
+ void* closure)
+{
+ mamaPublishTopic* topic = (mamaPublishTopic*) data;
+
+ free ((char*)topic->symbol);
+ free (topic);
+}

static void MAMACALLTYPE
inboxMsgCb (mamaMsg msg, void *closure)
@@ -339,10 +351,14 @@ void mamaDQPublisherManager_destroy (mamaDQPublisherManager manager)
}

/* Destroy the publisher table. */
- if(NULL != impl->mPublisherMap)
+ if (NULL != impl->mPublisherMap)
{
- wtable_destroy ( impl->mPublisherMap );
-}
+ wtable_clear_for_each (impl->mPublisherMap,
+ &cleanupPublisherMap,
+ NULL);
+
+ wtable_destroy (impl->mPublisherMap);
+ }

/* Free the impl itself. */
free(impl);
--
1.9.0


Damian Maguire <DMaguire@...>
 

Hey Lee,

As before, this is now in Bugzilla for tracking, if you want to add
yourself as a CC when you get an account setup.

Ticket Number: http://bugs.openmama.org/show_bug.cgi?id=69

Cheers,

D




On 2/24/14 2:32 PM, "Lee Skillen" <lskillen@vulcanft.com> wrote:

Fixed memory leak when calling dqPublisherManager_destroy() - The
contents of the publisher topic map are now freed inline with the
publisher map itself being destroyed.

Signed-off-by: Lee Skillen <lskillen@vulcanft.com>
---
mama/c_cpp/src/c/dqpublishermanager.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/mama/c_cpp/src/c/dqpublishermanager.c
b/mama/c_cpp/src/c/dqpublishermanager.c
index beb3a92..691973b 100644
--- a/mama/c_cpp/src/c/dqpublishermanager.c
+++ b/mama/c_cpp/src/c/dqpublishermanager.c
@@ -62,6 +62,18 @@ typedef struct mamaDQPublisherManagerImpl_

} mamaDQPublisherManagerImpl;

+static
+void cleanupPublisherMap (
+ wtable_t t,
+ void* data,
+ const char* key,
+ void* closure)
+{
+ mamaPublishTopic* topic = (mamaPublishTopic*) data;
+
+ free ((char*)topic->symbol);
+ free (topic);
+}

static void MAMACALLTYPE
inboxMsgCb (mamaMsg msg, void *closure)
@@ -339,10 +351,14 @@ void mamaDQPublisherManager_destroy
(mamaDQPublisherManager manager)
}

/* Destroy the publisher table. */
- if(NULL != impl->mPublisherMap)
+ if (NULL != impl->mPublisherMap)
{
- wtable_destroy ( impl->mPublisherMap );
-}
+ wtable_clear_for_each (impl->mPublisherMap,
+ &cleanupPublisherMap,
+ NULL);
+
+ wtable_destroy (impl->mPublisherMap);
+ }

/* Free the impl itself. */
free(impl);
--
1.9.0
________________________________________________________

This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange Group, Inc. (ICE), NYSE Euronext or any of their subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.
________________________________________________________