Mercurial > libavformat.hg
comparison cutils.c @ 151:ec4d9190d3b1 libavformat
dynamic array functions
author | bellard |
---|---|
date | Fri, 13 Jun 2003 14:22:23 +0000 |
parents | b0e0eb595e29 |
children | b0771ae979e3 |
comparison
equal
deleted
inserted
replaced
150:46e80c40ab9f | 151:ec4d9190d3b1 |
---|---|
106 pstrcpy(buf + len, buf_size - len, s); | 106 pstrcpy(buf + len, buf_size - len, s); |
107 return buf; | 107 return buf; |
108 } | 108 } |
109 | 109 |
110 #endif | 110 #endif |
111 | |
112 /* add one element to a dynamic array */ | |
113 void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem) | |
114 { | |
115 int nb, nb_alloc; | |
116 unsigned long *tab; | |
117 | |
118 nb = *nb_ptr; | |
119 tab = *tab_ptr; | |
120 if ((nb & (nb - 1)) == 0) { | |
121 if (nb == 0) | |
122 nb_alloc = 1; | |
123 else | |
124 nb_alloc = nb * 2; | |
125 tab = av_realloc(tab, nb_alloc * sizeof(unsigned long)); | |
126 *tab_ptr = tab; | |
127 } | |
128 tab[nb++] = elem; | |
129 *nb_ptr = nb; | |
130 } | |
131 |