Fix foreach_ptr_array() not to crash on arrays with 0 elements
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5906 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
cca0d7f5a9
commit
57bca3ba25
@ -1,3 +1,9 @@
|
||||
2011-08-25 Colomban Wendling <colomban(at)geany(dot)org>
|
||||
|
||||
* src/utils.h:
|
||||
Fix foreach_ptr_array() not to crash on arrays with 0 elements.
|
||||
|
||||
|
||||
2011-08-25 Colomban Wendling <colomban(at)geany(dot)org>
|
||||
|
||||
* src/document.c, src/filetypes.c, src/filetypes.h, doc/geany.txt,
|
||||
|
@ -84,8 +84,8 @@
|
||||
* @param idx @c guint index into @a ptr_array.
|
||||
* @param ptr_array @c GPtrArray to traverse. */
|
||||
#define foreach_ptr_array(item, idx, ptr_array) \
|
||||
for (idx = 0, item = g_ptr_array_index(ptr_array, 0); \
|
||||
idx < ptr_array->len; ++idx, item = g_ptr_array_index(ptr_array, idx))
|
||||
for (idx = 0, item = ((ptr_array)->len > 0 ? g_ptr_array_index((ptr_array), 0) : NULL); \
|
||||
idx < (ptr_array)->len; ++idx, item = g_ptr_array_index((ptr_array), idx))
|
||||
|
||||
/** Iterates all the nodes in @a list.
|
||||
* @param node should be a (@c GList*).
|
||||
|
Loading…
x
Reference in New Issue
Block a user