[vlc-commits] commit: array macros: assert arguments validity ( Rafaël Carré )
git at videolan.org
git at videolan.org
Thu Jun 17 05:50:07 CEST 2010
vlc | branch: master | Rafaël Carré <rafael.carre at gmail.com> | Sun Jun 13 20:55:55 2010 +0200| [8dcc306334630fc67fff7c2f624c247134406f1d] | committer: Rafaël Carré
array macros: assert arguments validity
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8dcc306334630fc67fff7c2f624c247134406f1d
---
include/vlc_arrays.h | 7 +++++++
src/playlist/tree.c | 1 -
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/include/vlc_arrays.h b/include/vlc_arrays.h
index 390c1b6..17baed3 100644
--- a/include/vlc_arrays.h
+++ b/include/vlc_arrays.h
@@ -25,6 +25,8 @@
#ifndef VLC_ARRAYS_H_
#define VLC_ARRAYS_H_
+#include <assert.h>
+
/**
* \file
* This file defines functions, structures and macros for handling arrays in vlc
@@ -48,6 +50,7 @@ static inline void *realloc_down( void *ptr, size_t size )
#define INSERT_ELEM( p_ar, i_oldsize, i_pos, elem ) \
do \
{ \
+ assert( i_pos <= i_oldsize ); \
if( !i_oldsize ) (p_ar) = NULL; \
(p_ar) = VLCCVP realloc( p_ar, ((i_oldsize) + 1) * sizeof(*(p_ar)) ); \
if( !(p_ar) ) abort(); \
@@ -64,6 +67,7 @@ static inline void *realloc_down( void *ptr, size_t size )
#define REMOVE_ELEM( p_ar, i_size, i_pos ) \
do \
{ \
+ assert( i_pos < i_size ); \
if( (i_size) - (i_pos) - 1 ) \
{ \
memmove( (p_ar) + (i_pos), \
@@ -147,6 +151,7 @@ static inline void *realloc_down( void *ptr, size_t size )
} while(0)
#define TAB_INSERT_CAST( cast, count, tab, p, index ) do { \
+ assert( index <= count ); \
if( (count) > 0 ) \
(tab) = cast realloc( tab, sizeof( void ** ) * ( (count) + 1 ) ); \
else \
@@ -262,6 +267,7 @@ static inline void *realloc_down( void *ptr, size_t size )
#define ARRAY_INSERT(array,elem,pos) \
do { \
+ assert( pos <= (array).i_size ); \
_ARRAY_GROW1(array); \
if( (array).i_size - pos ) { \
memmove( (array).p_elems + pos + 1, (array).p_elems + pos, \
@@ -273,6 +279,7 @@ static inline void *realloc_down( void *ptr, size_t size )
#define ARRAY_REMOVE(array,pos) \
do { \
+ assert( pos < (array).i_size ); \
if( (array).i_size - (pos) - 1 ) \
{ \
memmove( (array).p_elems + pos, (array).p_elems + pos + 1, \
diff --git a/src/playlist/tree.c b/src/playlist/tree.c
index dff0a73..e7fdebe 100644
--- a/src/playlist/tree.c
+++ b/src/playlist/tree.c
@@ -208,7 +208,6 @@ int playlist_NodeInsert( playlist_t *p_playlist,
(void)p_playlist;
assert( p_parent && p_parent->i_children != -1 );
if( i_position == -1 ) i_position = p_parent->i_children ;
- assert( i_position <= p_parent->i_children);
INSERT_ELEM( p_parent->pp_children,
p_parent->i_children,
More information about the vlc-commits
mailing list