[vlc-devel] commit: vlc_array: Macro safety. ( Rémi Duraffort )
git version control
git at videolan.org
Fri Sep 26 22:56:17 CEST 2008
vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Fri Sep 26 22:59:23 2008 +0200| [05c8c0d9164b349c8fe94386b4e5270c5d039339] | committer: Rémi Duraffort
vlc_array: Macro safety.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=05c8c0d9164b349c8fe94386b4e5270c5d039339
---
include/vlc_arrays.h | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/include/vlc_arrays.h b/include/vlc_arrays.h
index e7d8005..a121000 100644
--- a/include/vlc_arrays.h
+++ b/include/vlc_arrays.h
@@ -19,7 +19,8 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
#ifndef VLC_ARRAYS_H_
#define VLC_ARRAYS_H_
@@ -230,22 +231,28 @@
#define TYPEDEF_ARRAY(type, name) typedef DECL_ARRAY(type) name;
#define ARRAY_INIT(array) \
+ do { \
(array).i_alloc = 0; \
(array).i_size = 0; \
- (array).p_elems = NULL;
+ (array).p_elems = NULL; \
+ } while(0)
#define ARRAY_RESET(array) \
+ do { \
(array).i_alloc = 0; \
(array).i_size = 0; \
- free( (array).p_elems ); (array).p_elems = NULL;
+ free( (array).p_elems ); (array).p_elems = NULL; \
+ } while(0)
-#define ARRAY_APPEND(array, elem) { \
+#define ARRAY_APPEND(array, elem) \
+ do { \
_ARRAY_GROW1(array); \
(array).p_elems[(array).i_size] = elem; \
(array).i_size++; \
-}
+ } while(0)
-#define ARRAY_INSERT(array,elem,pos) { \
+#define ARRAY_INSERT(array,elem,pos) \
+ do { \
_ARRAY_GROW1(array); \
if( (array).i_size - pos ) { \
memmove( (array).p_elems + pos + 1, (array).p_elems + pos, \
@@ -253,9 +260,10 @@
} \
(array).p_elems[pos] = elem; \
(array).i_size++; \
-}
+ } while(0)
-#define ARRAY_REMOVE(array,pos) { \
+#define ARRAY_REMOVE(array,pos) \
+ do { \
if( (array).i_size - (pos) - 1 ) \
{ \
memmove( (array).p_elems + pos, (array).p_elems + pos + 1, \
@@ -263,7 +271,7 @@
} \
(array).i_size--; \
_ARRAY_SHRINK(array); \
-}
+ } while(0)
#define ARRAY_VAL(array, pos) array.p_elems[pos]
More information about the vlc-devel
mailing list