Commit b866f519 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

arrays: fix bogus cast in TAB_INSERT and TAB_ERASE

The cast, which is from the original stream output chain mega-patch,
assumed that all pointer types have same representation - which is
usually true. But it also assumed that tables would only contain
pointers; this might have been true back then, but it no longer is.
parent 209ee554
......@@ -116,11 +116,9 @@ static inline void *realloc_down( void *ptr, size_t size )
#define TAB_ERASE( count, tab, index ) \
do { \
if( (count) > 1 ) \
{ \
memmove( ((void**)(tab) + index), \
((void**)(tab) + index+1), \
( (count) - index - 1 ) * sizeof( *(tab) ) );\
} \
memmove( (tab) + (index), \
(tab) + (index) + 1, \
((count) - (index) - 1 ) * sizeof( *(tab) ) );\
(count)--; \
if( (count) == 0 ) \
{ \
......@@ -144,9 +142,9 @@ static inline void *realloc_down( void *ptr, size_t size )
(tab) = cast malloc( sizeof( *(tab) ) ); \
if( !(tab) ) abort(); \
if( (count) - (index) > 0 ) \
memmove( (void**)(tab) + (index) + 1, \
(void**)(tab) + (index), \
((count) - (index)) * sizeof(*(tab)) );\
memmove( (tab) + (index) + 1, \
(tab) + (index), \
((count) - (index)) * sizeof( *(tab) ) );\
(tab)[(index)] = (p); \
(count)++; \
} while(0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment