Blender  V3.3
BLI_array.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2008 Blender Foundation. All rights reserved. */
3 
33 #include <string.h>
34 
35 #include "BLI_array.h"
36 
37 #include "BLI_sys_types.h"
38 
39 #include "MEM_guardedalloc.h"
40 
41 void _bli_array_grow_func(void **arr_p,
42  const void *arr_static,
43  const int sizeof_arr_p,
44  const int arr_len,
45  const int num,
46  const char *alloc_str)
47 {
48  void *arr = *arr_p;
49  void *arr_tmp;
50 
51  arr_tmp = MEM_mallocN(sizeof_arr_p * ((num < arr_len) ? (arr_len * 2 + 2) : (arr_len + num)),
52  alloc_str);
53 
54  if (arr) {
55  memcpy(arr_tmp, arr, sizeof_arr_p * arr_len);
56 
57  if (arr != arr_static) {
58  MEM_freeN(arr);
59  }
60  }
61 
62  *arr_p = arr_tmp;
63 }
void _bli_array_grow_func(void **arr_p, const void *arr_static, const int sizeof_arr_p, const int arr_len, const int num, const char *alloc_str)
Definition: BLI_array.c:41
A (mainly) macro array library.
Read Guarded memory(de)allocation.
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33