FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavutil/mem.c
Date: 2024-02-16 17:37:06
Exec Total Coverage
Lines: 214 251 85.3%
Functions: 26 28 92.9%
Branches: 100 146 68.5%

Line Branch Exec Source
1 /*
2 * default memory allocator for libavutil
3 * Copyright (c) 2002 Fabrice Bellard
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * default memory allocator for libavutil
25 */
26
27 #define _XOPEN_SOURCE 600
28
29 #include "config.h"
30
31 #include <limits.h>
32 #include <stdint.h>
33 #include <stdlib.h>
34 #include <stdatomic.h>
35 #include <string.h>
36 #if HAVE_MALLOC_H
37 #include <malloc.h>
38 #endif
39
40 #include "attributes.h"
41 #include "avassert.h"
42 #include "dynarray.h"
43 #include "error.h"
44 #include "internal.h"
45 #include "intreadwrite.h"
46 #include "macros.h"
47 #include "mem.h"
48
49 #ifdef MALLOC_PREFIX
50
51 #define malloc AV_JOIN(MALLOC_PREFIX, malloc)
52 #define memalign AV_JOIN(MALLOC_PREFIX, memalign)
53 #define posix_memalign AV_JOIN(MALLOC_PREFIX, posix_memalign)
54 #define realloc AV_JOIN(MALLOC_PREFIX, realloc)
55 #define free AV_JOIN(MALLOC_PREFIX, free)
56
57 void *malloc(size_t size);
58 void *memalign(size_t align, size_t size);
59 int posix_memalign(void **ptr, size_t align, size_t size);
60 void *realloc(void *ptr, size_t size);
61 void free(void *ptr);
62
63 #endif /* MALLOC_PREFIX */
64
65 #define ALIGN (HAVE_AVX512 ? 64 : (HAVE_AVX ? 32 : 16))
66
67 /* NOTE: if you want to override these functions with your own
68 * implementations (not recommended) you have to link libav* as
69 * dynamic libraries and remove -Wl,-Bsymbolic from the linker flags.
70 * Note that this will cost performance. */
71
72 static atomic_size_t max_alloc_size = ATOMIC_VAR_INIT(INT_MAX);
73
74 void av_max_alloc(size_t max){
75 atomic_store_explicit(&max_alloc_size, max, memory_order_relaxed);
76 }
77
78 6900429 static int size_mult(size_t a, size_t b, size_t *r)
79 {
80 size_t t;
81
82 #if (!defined(__INTEL_COMPILER) && AV_GCC_VERSION_AT_LEAST(5,1)) || AV_HAS_BUILTIN(__builtin_mul_overflow)
83
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6900429 times.
6900429 if (__builtin_mul_overflow(a, b, &t))
84 return AVERROR(EINVAL);
85 #else
86 t = a * b;
87 /* Hack inspired from glibc: don't try the division if nelem and elsize
88 * are both less than sqrt(SIZE_MAX). */
89 if ((a | b) >= ((size_t)1 << (sizeof(size_t) * 4)) && a && t / a != b)
90 return AVERROR(EINVAL);
91 #endif
92 6900429 *r = t;
93 6900429 return 0;
94 }
95
96 25631832 void *av_malloc(size_t size)
97 {
98 25631832 void *ptr = NULL;
99
100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25631832 times.
25631832 if (size > atomic_load_explicit(&max_alloc_size, memory_order_relaxed))
101 return NULL;
102
103 #if HAVE_POSIX_MEMALIGN
104
2/2
✓ Branch 0 taken 25628437 times.
✓ Branch 1 taken 3395 times.
25631832 if (size) //OS X on SDK 10.6 has a broken posix_memalign implementation
105
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 25628437 times.
25628437 if (posix_memalign(&ptr, ALIGN, size))
106 ptr = NULL;
107 #elif HAVE_ALIGNED_MALLOC
108 ptr = _aligned_malloc(size, ALIGN);
109 #elif HAVE_MEMALIGN
110 #ifndef __DJGPP__
111 ptr = memalign(ALIGN, size);
112 #else
113 ptr = memalign(size, ALIGN);
114 #endif
115 /* Why 64?
116 * Indeed, we should align it:
117 * on 4 for 386
118 * on 16 for 486
119 * on 32 for 586, PPro - K6-III
120 * on 64 for K7 (maybe for P3 too).
121 * Because L1 and L2 caches are aligned on those values.
122 * But I don't want to code such logic here!
123 */
124 /* Why 32?
125 * For AVX ASM. SSE / NEON needs only 16.
126 * Why not larger? Because I did not see a difference in benchmarks ...
127 */
128 /* benchmarks with P3
129 * memalign(64) + 1 3071, 3051, 3032
130 * memalign(64) + 2 3051, 3032, 3041
131 * memalign(64) + 4 2911, 2896, 2915
132 * memalign(64) + 8 2545, 2554, 2550
133 * memalign(64) + 16 2543, 2572, 2563
134 * memalign(64) + 32 2546, 2545, 2571
135 * memalign(64) + 64 2570, 2533, 2558
136 *
137 * BTW, malloc seems to do 8-byte alignment by default here.
138 */
139 #else
140 ptr = malloc(size);
141 #endif
142
3/4
✓ Branch 0 taken 3395 times.
✓ Branch 1 taken 25628437 times.
✓ Branch 2 taken 3395 times.
✗ Branch 3 not taken.
25631832 if(!ptr && !size) {
143 3395 size = 1;
144 3395 ptr= av_malloc(1);
145 }
146 #if CONFIG_MEMORY_POISONING
147
1/2
✓ Branch 0 taken 25631832 times.
✗ Branch 1 not taken.
25631832 if (ptr)
148 25631832 memset(ptr, FF_MEMORY_POISON, size);
149 #endif
150 25631832 return ptr;
151 }
152
153 10170997 void *av_realloc(void *ptr, size_t size)
154 {
155 void *ret;
156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10170997 times.
10170997 if (size > atomic_load_explicit(&max_alloc_size, memory_order_relaxed))
157 return NULL;
158
159 #if HAVE_ALIGNED_MALLOC
160 ret = _aligned_realloc(ptr, size + !size, ALIGN);
161 #else
162 10170997 ret = realloc(ptr, size + !size);
163 #endif
164 #if CONFIG_MEMORY_POISONING
165
3/4
✓ Branch 0 taken 10170997 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6217457 times.
✓ Branch 3 taken 3953540 times.
10170997 if (ret && !ptr)
166 6217457 memset(ret, FF_MEMORY_POISON, size);
167 #endif
168 10170997 return ret;
169 }
170
171 62609 void *av_realloc_f(void *ptr, size_t nelem, size_t elsize)
172 {
173 size_t size;
174 void *r;
175
176
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 62609 times.
62609 if (size_mult(elsize, nelem, &size)) {
177 av_free(ptr);
178 return NULL;
179 }
180 62609 r = av_realloc(ptr, size);
181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62609 times.
62609 if (!r)
182 av_free(ptr);
183 62609 return r;
184 }
185
186 19483 int av_reallocp(void *ptr, size_t size)
187 {
188 void *val;
189
190
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 19474 times.
19483 if (!size) {
191 9 av_freep(ptr);
192 9 return 0;
193 }
194
195 19474 memcpy(&val, ptr, sizeof(val));
196 19474 val = av_realloc(val, size);
197
198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19474 times.
19474 if (!val) {
199 av_freep(ptr);
200 return AVERROR(ENOMEM);
201 }
202
203 19474 memcpy(ptr, &val, sizeof(val));
204 19474 return 0;
205 }
206
207 239631 void *av_malloc_array(size_t nmemb, size_t size)
208 {
209 size_t result;
210
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 239631 times.
239631 if (size_mult(nmemb, size, &result) < 0)
211 return NULL;
212 239631 return av_malloc(result);
213 }
214
215 4267648 void *av_realloc_array(void *ptr, size_t nmemb, size_t size)
216 {
217 size_t result;
218
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4267648 times.
4267648 if (size_mult(nmemb, size, &result) < 0)
219 return NULL;
220 4267648 return av_realloc(ptr, result);
221 }
222
223 4833 int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
224 {
225 void *val;
226
227 4833 memcpy(&val, ptr, sizeof(val));
228 4833 val = av_realloc_f(val, nmemb, size);
229 4833 memcpy(ptr, &val, sizeof(val));
230
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4833 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4833 if (!val && nmemb && size)
231 return AVERROR(ENOMEM);
232
233 4833 return 0;
234 }
235
236 74212352 void av_free(void *ptr)
237 {
238 #if HAVE_ALIGNED_MALLOC
239 _aligned_free(ptr);
240 #else
241 74212352 free(ptr);
242 #endif
243 74212352 }
244
245 64488354 void av_freep(void *arg)
246 {
247 void *val;
248
249 64488354 memcpy(&val, arg, sizeof(val));
250 64488354 memcpy(arg, &(void *){ NULL }, sizeof(val));
251 64488354 av_free(val);
252 64488354 }
253
254 20279366 void *av_mallocz(size_t size)
255 {
256 20279366 void *ptr = av_malloc(size);
257
1/2
✓ Branch 0 taken 20279366 times.
✗ Branch 1 not taken.
20279366 if (ptr)
258 20279366 memset(ptr, 0, size);
259 20279366 return ptr;
260 }
261
262 2329901 void *av_calloc(size_t nmemb, size_t size)
263 {
264 size_t result;
265
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 2329901 times.
2329901 if (size_mult(nmemb, size, &result) < 0)
266 return NULL;
267 2329901 return av_mallocz(result);
268 }
269
270 2591325 char *av_strdup(const char *s)
271 {
272 2591325 char *ptr = NULL;
273
2/2
✓ Branch 0 taken 2099617 times.
✓ Branch 1 taken 491708 times.
2591325 if (s) {
274 2099617 size_t len = strlen(s) + 1;
275 2099617 ptr = av_realloc(NULL, len);
276
1/2
✓ Branch 0 taken 2099617 times.
✗ Branch 1 not taken.
2099617 if (ptr)
277 2099617 memcpy(ptr, s, len);
278 }
279 2591325 return ptr;
280 }
281
282 char *av_strndup(const char *s, size_t len)
283 {
284 char *ret = NULL, *end;
285
286 if (!s)
287 return NULL;
288
289 end = memchr(s, 0, len);
290 if (end)
291 len = end - s;
292
293 ret = av_realloc(NULL, len + 1);
294 if (!ret)
295 return NULL;
296
297 memcpy(ret, s, len);
298 ret[len] = 0;
299 return ret;
300 }
301
302 96815 void *av_memdup(const void *p, size_t size)
303 {
304 96815 void *ptr = NULL;
305
1/2
✓ Branch 0 taken 96815 times.
✗ Branch 1 not taken.
96815 if (p) {
306 96815 ptr = av_malloc(size);
307
1/2
✓ Branch 0 taken 96815 times.
✗ Branch 1 not taken.
96815 if (ptr)
308 96815 memcpy(ptr, p, size);
309 }
310 96815 return ptr;
311 }
312
313 86790 int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
314 {
315 void **tab;
316 86790 memcpy(&tab, tab_ptr, sizeof(tab));
317
318
7/10
✓ Branch 0 taken 85535 times.
✓ Branch 1 taken 1255 times.
✓ Branch 2 taken 12475 times.
✓ Branch 3 taken 73060 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 85535 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 85535 times.
✓ Branch 9 taken 86790 times.
✗ Branch 10 not taken.
86790 FF_DYNARRAY_ADD(INT_MAX, sizeof(*tab), tab, *nb_ptr, {
319 tab[*nb_ptr] = elem;
320 memcpy(tab_ptr, &tab, sizeof(tab));
321 }, {
322 return AVERROR(ENOMEM);
323 });
324 86790 return 0;
325 }
326
327 1162 void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem)
328 {
329 void **tab;
330 1162 memcpy(&tab, tab_ptr, sizeof(tab));
331
332
7/10
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 935 times.
✓ Branch 2 taken 146 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 227 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 227 times.
✓ Branch 9 taken 1162 times.
✗ Branch 10 not taken.
1162 FF_DYNARRAY_ADD(INT_MAX, sizeof(*tab), tab, *nb_ptr, {
333 tab[*nb_ptr] = elem;
334 memcpy(tab_ptr, &tab, sizeof(tab));
335 }, {
336 *nb_ptr = 0;
337 av_freep(tab_ptr);
338 });
339 1162 }
340
341 531745 void *av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size,
342 const uint8_t *elem_data)
343 {
344 531745 uint8_t *tab_elem_data = NULL;
345
346
8/12
✓ Branch 0 taken 321135 times.
✓ Branch 1 taken 210610 times.
✓ Branch 2 taken 187413 times.
✓ Branch 3 taken 133722 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 321135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 321135 times.
✓ Branch 9 taken 531745 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 531745 times.
531745 FF_DYNARRAY_ADD(INT_MAX, elem_size, *tab_ptr, *nb_ptr, {
347 tab_elem_data = (uint8_t *)*tab_ptr + (*nb_ptr) * elem_size;
348 if (elem_data)
349 memcpy(tab_elem_data, elem_data, elem_size);
350 else if (CONFIG_MEMORY_POISONING)
351 memset(tab_elem_data, FF_MEMORY_POISON, elem_size);
352 }, {
353 av_freep(tab_ptr);
354 *nb_ptr = 0;
355 });
356 531745 return tab_elem_data;
357 }
358
359 165628 static void fill16(uint8_t *dst, int len)
360 {
361 165628 uint32_t v = AV_RN16(dst - 2);
362
363 165628 v |= v << 16;
364
365
2/2
✓ Branch 0 taken 85700138 times.
✓ Branch 1 taken 165628 times.
85865766 while (len >= 4) {
366 85700138 AV_WN32(dst, v);
367 85700138 dst += 4;
368 85700138 len -= 4;
369 }
370
371
2/2
✓ Branch 0 taken 319085 times.
✓ Branch 1 taken 165628 times.
484713 while (len--) {
372 319085 *dst = dst[-2];
373 319085 dst++;
374 }
375 165628 }
376
377 594 static void fill24(uint8_t *dst, int len)
378 {
379 #if HAVE_BIGENDIAN
380 uint32_t v = AV_RB24(dst - 3);
381 uint32_t a = v << 8 | v >> 16;
382 uint32_t b = v << 16 | v >> 8;
383 uint32_t c = v << 24 | v;
384 #else
385 594 uint32_t v = AV_RL24(dst - 3);
386 594 uint32_t a = v | v << 24;
387 594 uint32_t b = v >> 8 | v << 16;
388 594 uint32_t c = v >> 16 | v << 8;
389 #endif
390
391
2/2
✓ Branch 0 taken 348 times.
✓ Branch 1 taken 594 times.
942 while (len >= 12) {
392 348 AV_WN32(dst, a);
393 348 AV_WN32(dst + 4, b);
394 348 AV_WN32(dst + 8, c);
395 348 dst += 12;
396 348 len -= 12;
397 }
398
399
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 455 times.
594 if (len >= 4) {
400 139 AV_WN32(dst, a);
401 139 dst += 4;
402 139 len -= 4;
403 }
404
405
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 581 times.
594 if (len >= 4) {
406 13 AV_WN32(dst, b);
407 13 dst += 4;
408 13 len -= 4;
409 }
410
411
2/2
✓ Branch 0 taken 1436 times.
✓ Branch 1 taken 594 times.
2030 while (len--) {
412 1436 *dst = dst[-3];
413 1436 dst++;
414 }
415 594 }
416
417 14560 static void fill32(uint8_t *dst, int len)
418 {
419 14560 uint32_t v = AV_RN32(dst - 4);
420
421 #if HAVE_FAST_64BIT
422 14560 uint64_t v2= v + ((uint64_t)v<<32);
423
2/2
✓ Branch 0 taken 98850 times.
✓ Branch 1 taken 14560 times.
113410 while (len >= 32) {
424 98850 AV_WN64(dst , v2);
425 98850 AV_WN64(dst+ 8, v2);
426 98850 AV_WN64(dst+16, v2);
427 98850 AV_WN64(dst+24, v2);
428 98850 dst += 32;
429 98850 len -= 32;
430 }
431 #endif
432
433
2/2
✓ Branch 0 taken 54517 times.
✓ Branch 1 taken 14560 times.
69077 while (len >= 4) {
434 54517 AV_WN32(dst, v);
435 54517 dst += 4;
436 54517 len -= 4;
437 }
438
439
2/2
✓ Branch 0 taken 2266 times.
✓ Branch 1 taken 14560 times.
16826 while (len--) {
440 2266 *dst = dst[-4];
441 2266 dst++;
442 }
443 14560 }
444
445 824363 void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
446 {
447 824363 const uint8_t *src = &dst[-back];
448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 824363 times.
824363 if (!back)
449 return;
450
451
2/2
✓ Branch 0 taken 5265 times.
✓ Branch 1 taken 819098 times.
824363 if (back == 1) {
452 5265 memset(dst, *src, cnt);
453
2/2
✓ Branch 0 taken 165628 times.
✓ Branch 1 taken 653470 times.
819098 } else if (back == 2) {
454 165628 fill16(dst, cnt);
455
2/2
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 652876 times.
653470 } else if (back == 3) {
456 594 fill24(dst, cnt);
457
2/2
✓ Branch 0 taken 14560 times.
✓ Branch 1 taken 638316 times.
652876 } else if (back == 4) {
458 14560 fill32(dst, cnt);
459 } else {
460
2/2
✓ Branch 0 taken 103538 times.
✓ Branch 1 taken 534778 times.
638316 if (cnt >= 16) {
461 103538 int blocklen = back;
462
2/2
✓ Branch 0 taken 31656 times.
✓ Branch 1 taken 103538 times.
135194 while (cnt > blocklen) {
463 31656 memcpy(dst, src, blocklen);
464 31656 dst += blocklen;
465 31656 cnt -= blocklen;
466 31656 blocklen <<= 1;
467 }
468 103538 memcpy(dst, src, cnt);
469 103538 return;
470 }
471
2/2
✓ Branch 0 taken 116277 times.
✓ Branch 1 taken 418501 times.
534778 if (cnt >= 8) {
472 116277 AV_COPY32U(dst, src);
473 116277 AV_COPY32U(dst + 4, src + 4);
474 116277 src += 8;
475 116277 dst += 8;
476 116277 cnt -= 8;
477 }
478
2/2
✓ Branch 0 taken 383459 times.
✓ Branch 1 taken 151319 times.
534778 if (cnt >= 4) {
479 383459 AV_COPY32U(dst, src);
480 383459 src += 4;
481 383459 dst += 4;
482 383459 cnt -= 4;
483 }
484
2/2
✓ Branch 0 taken 192819 times.
✓ Branch 1 taken 341959 times.
534778 if (cnt >= 2) {
485 192819 AV_COPY16U(dst, src);
486 192819 src += 2;
487 192819 dst += 2;
488 192819 cnt -= 2;
489 }
490
2/2
✓ Branch 0 taken 118885 times.
✓ Branch 1 taken 415893 times.
534778 if (cnt)
491 118885 *dst = *src;
492 }
493 }
494
495 2081174 void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
496 {
497 size_t max_size;
498
499
2/2
✓ Branch 0 taken 1970474 times.
✓ Branch 1 taken 110700 times.
2081174 if (min_size <= *size)
500 1970474 return ptr;
501
502 110700 max_size = atomic_load_explicit(&max_alloc_size, memory_order_relaxed);
503 /* *size is an unsigned, so the real maximum is <= UINT_MAX. */
504 110700 max_size = FFMIN(max_size, UINT_MAX);
505
506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110700 times.
110700 if (min_size > max_size) {
507 *size = 0;
508 return NULL;
509 }
510
511 110700 min_size = FFMIN(max_size, FFMAX(min_size + min_size / 16 + 32, min_size));
512
513 110700 ptr = av_realloc(ptr, min_size);
514 /* we could set this to the unmodified min_size but this is safer
515 * if the user lost the ptr and uses NULL now
516 */
517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110700 times.
110700 if (!ptr)
518 min_size = 0;
519
520 110700 *size = min_size;
521
522 110700 return ptr;
523 }
524
525 367069 static inline void fast_malloc(void *ptr, unsigned int *size, size_t min_size, int zero_realloc)
526 {
527 size_t max_size;
528 void *val;
529
530 367069 memcpy(&val, ptr, sizeof(val));
531
2/2
✓ Branch 0 taken 322913 times.
✓ Branch 1 taken 44156 times.
367069 if (min_size <= *size) {
532
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 322913 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
322913 av_assert0(val || !min_size);
533 322913 return;
534 }
535
536 44156 max_size = atomic_load_explicit(&max_alloc_size, memory_order_relaxed);
537 /* *size is an unsigned, so the real maximum is <= UINT_MAX. */
538 44156 max_size = FFMIN(max_size, UINT_MAX);
539
540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44156 times.
44156 if (min_size > max_size) {
541 av_freep(ptr);
542 *size = 0;
543 return;
544 }
545 44156 min_size = FFMIN(max_size, FFMAX(min_size + min_size / 16 + 32, min_size));
546 44156 av_freep(ptr);
547
2/2
✓ Branch 0 taken 42194 times.
✓ Branch 1 taken 1962 times.
44156 val = zero_realloc ? av_mallocz(min_size) : av_malloc(min_size);
548 44156 memcpy(ptr, &val, sizeof(val));
549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44156 times.
44156 if (!val)
550 min_size = 0;
551 44156 *size = min_size;
552 44156 return;
553 }
554
555 89933 void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
556 {
557 89933 fast_malloc(ptr, size, min_size, 0);
558 89933 }
559
560 277136 void av_fast_mallocz(void *ptr, unsigned int *size, size_t min_size)
561 {
562 277136 fast_malloc(ptr, size, min_size, 1);
563 277136 }
564
565 640 int av_size_mult(size_t a, size_t b, size_t *r)
566 {
567 640 return size_mult(a, b, r);
568 }
569