Blender V5.3
BLI_mempool.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
10
11#include "BLI_compiler_attrs.hh"
12
13#include <type_traits>
14
15namespace blender {
16
17struct BLI_mempool;
19
20BLI_mempool *BLI_mempool_create(unsigned int esize,
21 unsigned int elem_num,
22 unsigned int pchunk,
23 unsigned int flag)
26 ATTR_NONNULL(1);
29
33template<typename T>
36{
37 static_assert(std::is_trivial_v<T>,
38 "Only trivial types may be allocated with BLI_mempool_alloc");
39 return static_cast<T *>(BLI_mempool_alloc(pool));
40}
41template<typename T>
43 ATTR_NONNULL(1) T *BLI_mempool_calloc(BLI_mempool *pool)
44{
45 static_assert(std::is_trivial_v<T>,
46 "Only trivial types may be allocated with BLI_mempool_calloc");
47 return static_cast<T *>(BLI_mempool_calloc(pool));
48}
49
55void BLI_mempool_free(BLI_mempool *pool, void *addr) ATTR_NONNULL(1, 2);
62void BLI_mempool_clear_ex(BLI_mempool *pool, int elem_num_reserve) ATTR_NONNULL(1);
71int BLI_mempool_len(const BLI_mempool *pool) ATTR_NONNULL(1);
73 ATTR_NONNULL(1);
74
78void BLI_mempool_as_array(BLI_mempool *pool, void *data) ATTR_NONNULL(1, 2);
83 const char *allocstr) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
84 ATTR_NONNULL(1, 2);
85
86#ifndef NDEBUG
88#endif
89
94
101
103enum {
114};
115
119void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter) ATTR_NONNULL();
123void *BLI_mempool_iterstep(BLI_mempool_iter *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
124
125} // namespace blender
#define ATTR_MALLOC
#define ATTR_WARN_UNUSED_RESULT
#define ATTR_RETURNS_NONNULL
#define ATTR_NONNULL(...)
#define T
BMesh Iterators.
Object ATTR_RETURNS_NONNULL
void void void BLI_mempool_set_memory_debug()
void BLI_mempool_free(BLI_mempool *pool, void *addr) ATTR_NONNULL(1
void BLI_mempool_destroy(BLI_mempool *pool) ATTR_NONNULL(1)
void BLI_mempool_as_array(BLI_mempool *pool, void *data) ATTR_NONNULL(1
BMesh const char void * data
void void * BLI_mempool_as_arrayN(BLI_mempool *pool, const char *allocstr) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
BLI_mempool * BLI_mempool_create(unsigned int esize, unsigned int elem_num, unsigned int pchunk, unsigned int flag) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter) ATTR_NONNULL()
void BLI_mempool_clear(BLI_mempool *pool) ATTR_NONNULL(1)
void * BLI_mempool_iterstep(BLI_mempool_iter *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void void BLI_mempool_clear_ex(BLI_mempool *pool, int elem_num_reserve) ATTR_NONNULL(1)
@ BLI_MEMPOOL_NOP
@ BLI_MEMPOOL_ALLOW_ITER
void * BLI_mempool_calloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void * BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
bool ATTR_WARN_UNUSED_RESULT
int BLI_mempool_len(const BLI_mempool *pool) ATTR_NONNULL(1)
void ATTR_NONNULL(1, 2)
char ATTR_MALLOC
Definition BLI_string.hh:79
void * BLI_mempool_findelem(BLI_mempool *pool, unsigned int index) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
struct BLI_mempool_chunk * curchunk