Blender V4.3
BLI_memiter.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
11#include "BLI_compiler_attrs.h"
12#include "BLI_compiler_compat.h"
13#include "BLI_sys_types.h"
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19/* 512kb, good default for small elems. */
20#define BLI_MEMITER_DEFAULT_SIZE (1 << 19)
21
22struct BLI_memiter;
23
24typedef struct BLI_memiter BLI_memiter;
25
35BLI_memiter *BLI_memiter_create(unsigned int chunk_size_min)
37void *BLI_memiter_alloc(BLI_memiter *mi, unsigned int elem_size)
38 /* WARNING: `ATTR_MALLOC` attribute on #BLI_memiter_alloc causes crash, see: D2756. */
40void BLI_memiter_alloc_from(BLI_memiter *mi, uint elem_size, const void *data_from)
41 ATTR_NONNULL(1, 3);
43 unsigned int elem_size) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
44 ATTR_NONNULL(1);
48
49/* Utilities. */
50
55void *BLI_memiter_elem_first_size(BLI_memiter *mi, unsigned int *r_size);
56
62
67 ATTR_NONNULL(1, 2);
68
69#ifdef __cplusplus
70}
71#endif
#define ATTR_WARN_UNUSED_RESULT
#define ATTR_MALLOC
#define ATTR_RETURNS_NONNULL
#define ATTR_NONNULL(...)
void * BLI_memiter_elem_first(BLI_memiter *mi)
void BLI_memiter_destroy(BLI_memiter *mi) ATTR_NONNULL(1)
void bool BLI_memiter_iter_done(const BLI_memiter_handle *iter) ATTR_NONNULL(1)
struct BLI_memiter_handle BLI_memiter_handle
void BLI_memiter_alloc_from(BLI_memiter *mi, uint elem_size, const void *data_from) ATTR_NONNULL(1
unsigned int BLI_memiter_count(const BLI_memiter *mi) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_memiter_iter_step(BLI_memiter_handle *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_memiter_elem_first_size(BLI_memiter *mi, unsigned int *r_size)
BLI_memiter * BLI_memiter_create(unsigned int chunk_size_min) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
void * BLI_memiter_alloc(BLI_memiter *mi, unsigned int elem_size) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void void * BLI_memiter_calloc(BLI_memiter *mi, unsigned int elem_size) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void BLI_memiter_clear(BLI_memiter *mi) ATTR_NONNULL(1)
void BLI_memiter_iter_init(BLI_memiter *mi, BLI_memiter_handle *iter) ATTR_NONNULL(1
void * BLI_memiter_iter_step_size(BLI_memiter_handle *iter, uint *r_size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
unsigned int uint
struct BLI_memiter_elem * elem
Definition BLI_memiter.h:59