glibmm r651 - in trunk: . glib/src



Author: murrayc
Date: Fri Apr 11 17:01:00 2008
New Revision: 651
URL: http://svn.gnome.org/viewvc/glibmm?rev=651&view=rev

Log:
2008-04-11  Murray Cumming  <murrayc murrayc com>

* glib/src/optionentry.ccg:
* glib/src/optionentry.hg: Hand-code set_description(), 
set_arg_description() and set_long_name(), to free any existing string, 
to maybe fix a (possible) leak found by valgrind.

Modified:
   trunk/ChangeLog
   trunk/glib/src/optionentry.ccg
   trunk/glib/src/optionentry.hg

Modified: trunk/glib/src/optionentry.ccg
==============================================================================
--- trunk/glib/src/optionentry.ccg	(original)
+++ trunk/glib/src/optionentry.ccg	Fri Apr 11 17:01:00 2008
@@ -74,6 +74,39 @@
   return *this;
 }
 
+void OptionEntry::set_long_name(const Glib::ustring& value)
+{
+  if(gobject_->long_name)
+  {
+    g_free((gchar*)(gobject_->long_name));
+    gobject_->long_name = NULL;
+  }
+
+  gobject_->long_name = (value).empty() ? NULL : g_strdup((value).c_str());
+}
+
+void OptionEntry::set_description(const Glib::ustring& value)
+{
+  if(gobject_->description)
+  {
+    g_free((gchar*)(gobject_->description));
+    gobject_->description = NULL;
+  }
+
+  gobj()->description = (value).empty() ? NULL : g_strdup((value).c_str());
+}
+
+void OptionEntry::set_arg_description(const Glib::ustring& value)
+{
+  if(gobject_->arg_description)
+  {
+    g_free((gchar*)(gobject_->arg_description));
+    gobject_->arg_description = NULL;
+  }
+
+  gobj()->arg_description = (value).empty() ? NULL : g_strdup((value).c_str());
+}
+ 
 
 } // namespace Glib
 

Modified: trunk/glib/src/optionentry.hg
==============================================================================
--- trunk/glib/src/optionentry.hg	(original)
+++ trunk/glib/src/optionentry.hg	Fri Apr 11 17:01:00 2008
@@ -65,10 +65,11 @@
   
   OptionEntry& operator=(const OptionEntry& src);
 
-#m4 _CONVERSION(`Glib::ustring',`const gchar*',`($3).empty() ? NULL : g_strdup(($3).c_str())')
+  //#m4 _CONVERSION(`Glib::ustring',`const gchar*',`($3).empty() ? NULL : g_strdup(($3).c_str())')
   
   _MEMBER_GET(long_name, long_name, Glib::ustring, const char*)
-  _MEMBER_SET(long_name, long_name, Glib::ustring, const char*)
+
+  void set_long_name(const Glib::ustring& value);
   
   _MEMBER_GET(short_name, short_name, gchar, gchar)
   _MEMBER_SET(short_name, short_name, gchar, gchar)
@@ -79,10 +80,14 @@
   //TODO: G_OPTION_ARG_CALLBACK,
     
   _MEMBER_GET(description, description, Glib::ustring, const char*)
-  _MEMBER_SET(description, description, Glib::ustring, const char*)
+
+  void set_description(const Glib::ustring& value);
+  
   
   _MEMBER_GET(arg_description, arg_description, Glib::ustring, const char*)
-  _MEMBER_SET(arg_description, arg_description, Glib::ustring, const char*)
+
+  void set_arg_description(const Glib::ustring& value);
+  
   
   GOptionEntry*       gobj()       { return gobject_; }
   const GOptionEntry* gobj() const { return gobject_; }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]