Blender
V3.3
|
A (mainly) macro array library. More...
Go to the source code of this file.
Macros | |
Internal defines | |
#define | _bli_array_totalsize_dynamic(arr) (((arr) == NULL) ? 0 : MEM_allocN_len(arr) / sizeof(*(arr))) |
#define | _bli_array_totalsize_static(arr) (sizeof(_##arr##_static) / sizeof(*(arr))) |
#define | _bli_array_totalsize(arr) |
Public defines | |
#define | BLI_array_declare(arr) |
#define | BLI_array_staticdeclare(arr, maxstatic) |
#define | BLI_array_len(arr) ((void)0, _##arr##_len) |
#define | BLI_array_reserve(arr, num) |
#define | BLI_array_grow_items(arr, num) (BLI_array_reserve(arr, num), (_##arr##_len += num)) |
#define | BLI_array_grow_one(arr) BLI_array_grow_items(arr, 1) |
#define | BLI_array_append(arr, item) ((void)BLI_array_grow_one(arr), (void)(arr[_##arr##_len - 1] = item)) |
#define | BLI_array_append_r(arr, item) ((void)BLI_array_grow_one(arr), (void)(arr[_##arr##_len - 1] = item), (&arr[_##arr##_len - 1])) |
#define | BLI_array_append_ret(arr) (BLI_array_reserve(arr, 1), &arr[(_##arr##_len++)]) |
#define | BLI_array_free(arr) |
#define | BLI_array_pop(arr) ((arr && _##arr##_len) ? arr[--_##arr##_len] : NULL) |
#define | BLI_array_clear(arr) |
#define | BLI_array_len_set(arr, len) |
#define | BLI_array_fake_user(arr) ((void)_##arr##_len, (void)_##arr##_static) |
#define | BLI_array_trim(arr) |
Generic Array Utils | |
Other useful defines (unrelated to the main array macros). | |
#define | BLI_array_fixedstack_declare(arr, maxstatic, realsize, allocstr) |
#define | BLI_array_fixedstack_free(arr) |
Functions | |
void | _bli_array_grow_func (void **arr_p, const void *arr_static, int sizeof_arr_p, int arr_len, int num, const char *alloc_str) |
A (mainly) macro array library.
Definition in file BLI_array.h.
#define _bli_array_totalsize | ( | arr | ) |
Definition at line 21 of file BLI_array.h.
#define _bli_array_totalsize_dynamic | ( | arr | ) | (((arr) == NULL) ? 0 : MEM_allocN_len(arr) / sizeof(*(arr))) |
This returns the entire size of the array, including any buffering.
Definition at line 16 of file BLI_array.h.
#define _bli_array_totalsize_static | ( | arr | ) | (sizeof(_##arr##_static) / sizeof(*(arr))) |
Definition at line 19 of file BLI_array.h.
#define BLI_array_append | ( | arr, | |
item | |||
) | ((void)BLI_array_grow_one(arr), (void)(arr[_##arr##_len - 1] = item)) |
Appends an item to the array.
Definition at line 98 of file BLI_array.h.
#define BLI_array_append_r | ( | arr, | |
item | |||
) | ((void)BLI_array_grow_one(arr), (void)(arr[_##arr##_len - 1] = item), (&arr[_##arr##_len - 1])) |
Appends an item to the array and returns a pointer to the item in the array. item is not a pointer, but actual data value.
Definition at line 105 of file BLI_array.h.
#define BLI_array_append_ret | ( | arr | ) | (BLI_array_reserve(arr, 1), &arr[(_##arr##_len++)]) |
Appends (grows) & returns a pointer to the uninitialized memory.
Definition at line 111 of file BLI_array.h.
#define BLI_array_clear | ( | arr | ) |
Resets the logical size of an array to zero, but doesn't free the memory.
Definition at line 128 of file BLI_array.h.
#define BLI_array_declare | ( | arr | ) |
use sizeof(*(arr))
to ensure the array exists and is an array
Definition at line 50 of file BLI_array.h.
Only to prevent unused warnings.
Definition at line 147 of file BLI_array.h.
#define BLI_array_fixedstack_declare | ( | arr, | |
maxstatic, | |||
realsize, | |||
allocstr | |||
) |
Not part of the 'API' but handy functions, same purpose as BLI_array_staticdeclare() but use when the max size is known ahead of time.
Definition at line 172 of file BLI_array.h.
#define BLI_array_fixedstack_free | ( | arr | ) |
Definition at line 179 of file BLI_array.h.
#define BLI_array_free | ( | arr | ) |
Definition at line 113 of file BLI_array.h.
#define BLI_array_grow_items | ( | arr, | |
num | |||
) | (BLI_array_reserve(arr, num), (_##arr##_len += num)) |
Returns length of array.
Definition at line 91 of file BLI_array.h.
#define BLI_array_grow_one | ( | arr | ) | BLI_array_grow_items(arr, 1) |
Definition at line 93 of file BLI_array.h.
returns the logical size of the array, not including buffering.
Definition at line 63 of file BLI_array.h.
Set the length of the array, doesn't actually increase the allocated array size. Don't use this unless you know what you're doing.
Definition at line 138 of file BLI_array.h.
Definition at line 122 of file BLI_array.h.
#define BLI_array_reserve | ( | arr, | |
num | |||
) |
Grow the array by a fixed number of items.
Allow for a large 'num' value when the new size is more than double to allocate the exact sized array.
Definition at line 71 of file BLI_array.h.
#define BLI_array_staticdeclare | ( | arr, | |
maxstatic | |||
) |
This will use stack space, up to maxstatic
array elements, before switching to dynamic heap allocation.
Definition at line 58 of file BLI_array.h.
#define BLI_array_trim | ( | arr | ) |
Trim excess items from the array (when they exist).
Definition at line 152 of file BLI_array.h.
void _bli_array_grow_func | ( | void ** | arr_p, |
const void * | arr_static, | ||
int | sizeof_arr_p, | ||
int | arr_len, | ||
int | num, | ||
const char * | alloc_str | ||
) |
Doing the reallocation in a macro isn't so simple, so use a function the macros can use.
This function is only to be called via macros.
Definition at line 41 of file BLI_array.c.
References MEM_freeN, and MEM_mallocN.