From 1b6b843f01e38f805478e40892c3c12156016363 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Wed, 1 Sep 2004 10:05:54 +0000 Subject: [PATCH] Optimized macros: FREE_LIST_ITEMS and COUNT_LIST_ITEMS. --- src/xpdev/gen_defs.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/xpdev/gen_defs.h b/src/xpdev/gen_defs.h index 0dccdd65fa..10cbdc0d49 100644 --- a/src/xpdev/gen_defs.h +++ b/src/xpdev/gen_defs.h @@ -256,13 +256,15 @@ typedef struct { /* Handy Pointer-freeing Macros */ /********************************/ #define FREE_AND_NULL(x) if(x!=NULL) { FREE(x); x=NULL; } -#define FREE_LIST_ITEMS(list,i) for(i=0;list!=NULL && list[i]!=NULL;i++) \ - { FREE_AND_NULL(list[i]); } +#define FREE_LIST_ITEMS(list,i) if(list!=NULL) { \ + for(i=0;list[i]!=NULL;i++) \ + FREE_AND_NULL(list[i]); \ + } #define FREE_LIST(list,i) FREE_LIST_ITEMS(list,i) FREE_AND_NULL(list) /********************************/ /* Other Pointer-List Macros */ /********************************/ -#define COUNT_LIST_ITEMS(list,i) for(i=0;list!=NULL && list[i]!=NULL;i++); +#define COUNT_LIST_ITEMS(list,i) { i=0; if(list!=NULL) while(list[i]!=NULL) i++; } #endif /* Don't add anything after this #endif statement */ -- GitLab