Revision: 1567 http://svn.sourceforge.net/geany/?rev=1567&view=rev Author: ntrel Date: 2007-05-24 09:00:48 -0700 (Thu, 24 May 2007)
Log Message: ----------- Add setptr() macro to free data and reassign to the same pointer.
Modified Paths: -------------- trunk/ChangeLog trunk/src/utils.h
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-05-24 10:24:26 UTC (rev 1566) +++ trunk/ChangeLog 2007-05-24 16:00:48 UTC (rev 1567) @@ -1,3 +1,9 @@ +2007-05-24 Nick Treleaven nick.treleaven@btinternet.com + + * src/utils.h: + Add setptr() macro to free data and reassign to the same pointer. + + 2007-05-24 Enrico Tröger enrico.troeger@uvena.de
* src/document.c: Fix loading of UTF-16/32 encoded files with a BOM.
Modified: trunk/src/utils.h =================================================================== --- trunk/src/utils.h 2007-05-24 10:24:26 UTC (rev 1566) +++ trunk/src/utils.h 2007-05-24 16:00:48 UTC (rev 1567) @@ -29,7 +29,17 @@ #define NZV(ptr) \ ((ptr) && (ptr)[0])
+/* Free's ptr (if not NULL), then assigns result to it. + * result can be an expression using the 'old' value of ptr. + * It prevents a memory leak compared with: ptr = func(ptr); */ +#define setptr(ptr, result)\ + {\ + gpointer tmp = ptr;\ + ptr = result;\ + g_free(tmp);\ + }
+ void utils_start_browser(const gchar *uri);
/* taken from anjuta, to determine the EOL mode of the file */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.