Blender  V3.3
Functions
BLI_array.c File Reference

A (mainly) macro array library. More...

#include <string.h>
#include "BLI_array.h"
#include "BLI_sys_types.h"
#include "MEM_guardedalloc.h"

Go to the source code of this file.

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)
 

Detailed Description

A (mainly) macro array library.

This is an array library, used to manage array (re)allocation.

Note
This is primarily accessed via macros, functions are used to implement some of the internals.

Example usage:

int *arr = NULL;
int i;
for (i = 0; i < 10; i++) {
arr[i] = something;
}
#define BLI_array_grow_one(arr)
Definition: BLI_array.h:93
#define BLI_array_declare(arr)
Definition: BLI_array.h:50
#define BLI_array_free(arr)
Definition: BLI_array.h:113

Arrays are over allocated, so each reallocation the array size is doubled. In situations where contiguous array access isn't needed, other solutions for allocation are available. Consider using on of: BLI_memarena.c, BLI_mempool.c, BLi_stack.c

Definition in file BLI_array.c.

Function Documentation

◆ _bli_array_grow_func()

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 
)

BLI_array.c

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.

Note
The caller must adjust arr_len

Definition at line 41 of file BLI_array.c.

References MEM_freeN, and MEM_mallocN.