diff options
author | Fabrice Bellard <fabrice@bellard.org> | 2003-06-13 14:22:23 +0000 |
---|---|---|
committer | Fabrice Bellard <fabrice@bellard.org> | 2003-06-13 14:22:23 +0000 |
commit | 39f472c3b6dd8405b33ad3c59f0b52046a393938 (patch) | |
tree | c173fc0b8904e494ba60783c6f2f588c9b99601d /libavformat/cutils.c | |
parent | 124ba5836fb896e580de0ed5d2f2b0b2daee4a27 (diff) | |
download | ffmpeg-39f472c3b6dd8405b33ad3c59f0b52046a393938.tar.gz |
dynamic array functions
Originally committed as revision 1955 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/cutils.c')
-rw-r--r-- | libavformat/cutils.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libavformat/cutils.c b/libavformat/cutils.c index 3e46533c6b..28f40b0e2f 100644 --- a/libavformat/cutils.c +++ b/libavformat/cutils.c @@ -108,3 +108,24 @@ char *pstrcat(char *buf, int buf_size, const char *s) } #endif + +/* add one element to a dynamic array */ +void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem) +{ + int nb, nb_alloc; + unsigned long *tab; + + nb = *nb_ptr; + tab = *tab_ptr; + if ((nb & (nb - 1)) == 0) { + if (nb == 0) + nb_alloc = 1; + else + nb_alloc = nb * 2; + tab = av_realloc(tab, nb_alloc * sizeof(unsigned long)); + *tab_ptr = tab; + } + tab[nb++] = elem; + *nb_ptr = nb; +} + |