From bcc887c0b13e75a161e09e2f3c4ddaeaa9fb60d7 Mon Sep 17 00:00:00 2001 From: ehouse Date: Fri, 31 Jul 2009 12:39:47 +0000 Subject: [PATCH] Need to remove before inserting. Todo: is there a replace? --- xwords4/relay/configs.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xwords4/relay/configs.cpp b/xwords4/relay/configs.cpp index bc112a27f..3152f98a4 100644 --- a/xwords4/relay/configs.cpp +++ b/xwords4/relay/configs.cpp @@ -126,7 +126,13 @@ void RelayConfigs::SetValueFor( const char* key, const char* value ) { MutexLock ml( &m_values_mutex ); - /* Does this leak in the case where we're replacing a value? */ + + /* Remove any entry already there */ + map::iterator iter = m_values.find(key); + if ( iter != m_values.end() ) { + m_values.erase(iter); + } + m_values.insert( pair(strdup(key),strdup(value) ) ); }