Add setptr() macro to free data and reassign to the same pointer.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1567 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2007-05-24 16:00:48 +00:00
parent 5331b0ada0
commit b7e499529d
2 changed files with 16 additions and 0 deletions

View File

@ -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.

View File

@ -29,6 +29,16 @@
#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);