Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
2bb0711d
Commit
2bb0711d
authored
Sep 26, 2008
by
Rémi Duraffort
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vlc_array: macro safety.
parent
b34411ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
30 deletions
+30
-30
include/vlc_arrays.h
include/vlc_arrays.h
+30
-30
No files found.
include/vlc_arrays.h
View file @
2bb0711d
...
@@ -188,33 +188,33 @@
...
@@ -188,33 +188,33 @@
/* Internal functions */
/* Internal functions */
#define _ARRAY_ALLOC(array, newsize) { \
#define _ARRAY_ALLOC(array, newsize) { \
array.i_alloc = newsize;
\
(array).i_alloc = newsize;
\
array.p_elems = VLCCVP realloc( array.p_elems, array.i_alloc *
\
(array).p_elems = VLCCVP realloc( (array).p_elems, (array).i_alloc *
\
sizeof(*
array.p_elems) );
\
sizeof(*
(array).p_elems) );
\
}
}
#define _ARRAY_GROW1(array) { \
#define _ARRAY_GROW1(array) { \
if(
array.i_alloc < 10 )
\
if(
(array).i_alloc < 10 )
\
_ARRAY_ALLOC(array, 10 ) \
_ARRAY_ALLOC(array, 10 ) \
else if(
array.i_alloc == array.i_size )
\
else if(
(array).i_alloc == (array).i_size )
\
_ARRAY_ALLOC(array, (int)(array.i_alloc * 1.5) ) \
_ARRAY_ALLOC(array, (int)(array.i_alloc * 1.5) ) \
}
}
#define _ARRAY_GROW(array,additional) { \
#define _ARRAY_GROW(array,additional) { \
int i_first =
array.i_alloc;
\
int i_first =
(array).i_alloc;
\
while(
array.i_alloc - i_first < additional )
\
while(
(array).i_alloc - i_first < additional )
\
{ \
{ \
if(
array.i_alloc < 10 )
\
if(
(array).i_alloc < 10 )
\
_ARRAY_ALLOC(array, 10 ) \
_ARRAY_ALLOC(array, 10 ) \
else if(
array.i_alloc == array.i_size )
\
else if(
(array).i_alloc == (array).i_size )
\
_ARRAY_ALLOC(array, (int)(
array.i_alloc * 1.5) )
\
_ARRAY_ALLOC(array, (int)(
(array).i_alloc * 1.5) )
\
else break; \
else break; \
} \
} \
}
}
#define _ARRAY_SHRINK(array) { \
#define _ARRAY_SHRINK(array) { \
if(
array.i_size > 10 && array.i_size < (int)(array
.i_alloc / 1.5) ) { \
if(
(array).i_size > 10 && (array).i_size < (int)((array)
.i_alloc / 1.5) ) { \
_ARRAY_ALLOC(array,
array.i_size + 5);
\
_ARRAY_ALLOC(array,
(array).i_size + 5);
\
} \
} \
}
}
...
@@ -230,45 +230,45 @@
...
@@ -230,45 +230,45 @@
#define TYPEDEF_ARRAY(type, name) typedef DECL_ARRAY(type) name;
#define TYPEDEF_ARRAY(type, name) typedef DECL_ARRAY(type) name;
#define ARRAY_INIT(array) \
#define ARRAY_INIT(array) \
array.i_alloc = 0;
\
(array).i_alloc = 0;
\
array.i_size = 0;
\
(array).i_size = 0;
\
array
.p_elems = NULL;
(array)
.p_elems = NULL;
#define ARRAY_RESET(array) \
#define ARRAY_RESET(array) \
array.i_alloc = 0;
\
(array).i_alloc = 0;
\
array.i_size = 0;
\
(array).i_size = 0;
\
free(
array.p_elems ); array
.p_elems = NULL;
free(
(array).p_elems ); (array)
.p_elems = NULL;
#define ARRAY_APPEND(array, elem) { \
#define ARRAY_APPEND(array, elem) { \
_ARRAY_GROW1(array); \
_ARRAY_GROW1(array); \
array.p_elems[array.i_size] = elem;
\
(array).p_elems[(array).i_size] = elem;
\
array.i_size++;
\
(array).i_size++;
\
}
}
#define ARRAY_INSERT(array,elem,pos) { \
#define ARRAY_INSERT(array,elem,pos) { \
_ARRAY_GROW1(array); \
_ARRAY_GROW1(array); \
if(
array.i_size - pos ) {
\
if(
(array).i_size - pos ) {
\
memmove(
array.p_elems + pos + 1, array.p_elems + pos,
\
memmove(
(array).p_elems + pos + 1, (array).p_elems + pos,
\
(
array.i_size-pos) * sizeof(*array.p_elems) );
\
(
(array).i_size-pos) * sizeof(*(array).p_elems) );
\
} \
} \
array.p_elems[pos] = elem;
\
(array).p_elems[pos] = elem;
\
array.i_size++;
\
(array).i_size++;
\
}
}
#define ARRAY_REMOVE(array,pos) { \
#define ARRAY_REMOVE(array,pos) { \
if(
array.i_size - (pos) - 1 )
\
if(
(array).i_size - (pos) - 1 )
\
{ \
{ \
memmove(
array.p_elems + pos, array.p_elems + pos + 1,
\
memmove(
(array).p_elems + pos, (array).p_elems + pos + 1,
\
(
array.i_size - pos - 1 ) *sizeof(*array.p_elems) );
\
(
(array).i_size - pos - 1 ) *sizeof(*(array).p_elems) );
\
} \
} \
array.i_size--;
\
(array).i_size--;
\
_ARRAY_SHRINK(array); \
_ARRAY_SHRINK(array); \
}
}
#define ARRAY_VAL(array, pos) array.p_elems[pos]
#define ARRAY_VAL(array, pos) array.p_elems[pos]
#define ARRAY_BSEARCH(array, elem, zetype, key, answer) \
#define ARRAY_BSEARCH(array, elem, zetype, key, answer) \
BSEARCH(
array.p_elems, array
.i_size, elem, zetype, key, answer)
BSEARCH(
(array).p_elems, (array)
.i_size, elem, zetype, key, answer)
#define FOREACH_ARRAY( item, array ) { \
#define FOREACH_ARRAY( item, array ) { \
int fe_idx; \
int fe_idx; \
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment