| 2119 | } |
| 2120 | |
| 2121 | static int opt_copy_array(void *logctx, const AVOption *o, |
| 2122 | void **pdst, const void * const *psrc) |
| 2123 | { |
| 2124 | unsigned nb_elems = *opt_array_pcount(psrc); |
| 2125 | void *dst = NULL; |
| 2126 | int ret; |
| 2127 | |
| 2128 | if (*pdst == *psrc) { |
| 2129 | *pdst = NULL; |
| 2130 | *opt_array_pcount(pdst) = 0; |
| 2131 | } |
| 2132 | |
| 2133 | opt_free_array(o, pdst, opt_array_pcount(pdst)); |
| 2134 | |
| 2135 | dst = av_calloc(nb_elems, opt_type_desc[TYPE_BASE(o->type)].size); |
| 2136 | if (!dst) |
| 2137 | return AVERROR(ENOMEM); |
| 2138 | |
| 2139 | for (unsigned i = 0; i < nb_elems; i++) { |
| 2140 | ret = opt_copy_elem(logctx, TYPE_BASE(o->type), |
| 2141 | opt_array_pelem(o, dst, i), |
| 2142 | opt_array_pelem(o, *(void**)psrc, i)); |
| 2143 | if (ret < 0) { |
| 2144 | opt_free_array(o, &dst, &nb_elems); |
| 2145 | return ret; |
| 2146 | } |
| 2147 | } |
| 2148 | |
| 2149 | *pdst = dst; |
| 2150 | *opt_array_pcount(pdst) = nb_elems; |
| 2151 | |
| 2152 | return 0; |
| 2153 | } |
| 2154 | |
| 2155 | int av_opt_copy(void *dst, const void *src) |
| 2156 | { |
no test coverage detected