|
Blender
V2.93
|
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) |
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, const int sizeof_arr_p, const int arr_len, const 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 37 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 32 of file BLI_array.h.
| #define _bli_array_totalsize_static | ( | arr | ) | (sizeof(_##arr##_static) / sizeof(*(arr))) |
Definition at line 35 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 104 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 110 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 114 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 130 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 62 of file BLI_array.h.
| #define BLI_array_fake_user | ( | arr | ) | ((void)_##arr##_len, (void)_##arr##_static) |
only to prevent unused warnings
Definition at line 146 of file BLI_array.h.
| #define BLI_array_fixedstack_declare | ( | arr, | |
| maxstatic, | |||
| realsize, | |||
| allocstr | |||
| ) |
not part of the 'API' but handy funcs, same purpose as BLI_array_staticdeclare() but use when the max size is known ahead of time
Definition at line 161 of file BLI_array.h.
| #define BLI_array_fixedstack_free | ( | arr | ) |
Definition at line 168 of file BLI_array.h.
| #define BLI_array_free | ( | arr | ) |
Definition at line 116 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 99 of file BLI_array.h.
| #define BLI_array_grow_one | ( | arr | ) | BLI_array_grow_items(arr, 1) |
Definition at line 101 of file BLI_array.h.
| #define BLI_array_len | ( | arr | ) | ((void)0, _##arr##_len) |
returns the logical size of the array, not including buffering.
Definition at line 74 of file BLI_array.h.
| #define BLI_array_len_set | ( | arr, | |
| len | |||
| ) |
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 139 of file BLI_array.h.
| #define BLI_array_pop | ( | arr | ) | ((arr && _##arr##_len) ? arr[--_##arr##_len] : NULL) |
Definition at line 125 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 81 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 69 of file BLI_array.h.
| 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 | ||
| ) |
Doing the realloc 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 62 of file BLI_array.c.
References MEM_freeN, and MEM_mallocN.