Blender V5.0
BLI_mempool.h
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.h"
12
13#include <type_traits>
14
15struct BLI_mempool;
17
18BLI_mempool *BLI_mempool_create(unsigned int esize,
19 unsigned int elem_num,
20 unsigned int pchunk,
21 unsigned int flag)
24 ATTR_NONNULL(1);
27
31template<typename T>
34{
35 static_assert(std::is_trivial_v<T>,
36 "Only trivial types may be allocated with BLI_mempool_alloc");
37 return static_cast<T *>(BLI_mempool_alloc(pool));
38}
39template<typename T>
42{
43 static_assert(std::is_trivial_v<T>,
44 "Only trivial types may be allocated with BLI_mempool_calloc");
45 return static_cast<T *>(BLI_mempool_calloc(pool));
46}
47
53void BLI_mempool_free(BLI_mempool *pool, void *addr) ATTR_NONNULL(1, 2);
60void BLI_mempool_clear_ex(BLI_mempool *pool, int elem_num_reserve) ATTR_NONNULL(1);
69int BLI_mempool_len(const BLI_mempool *pool) ATTR_NONNULL(1);
70void *BLI_mempool_findelem(BLI_mempool *pool, unsigned int index) ATTR_WARN_UNUSED_RESULT
71 ATTR_NONNULL(1);
72
81 const char *allocstr) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
82 ATTR_NONNULL(1, 2);
83
84#ifndef NDEBUG
86#endif
87
92
99
101enum {
112};
113
#define ATTR_WARN_UNUSED_RESULT
#define ATTR_MALLOC
#define ATTR_RETURNS_NONNULL
#define ATTR_NONNULL(...)
void * BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter) ATTR_NONNULL()
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)
void void * BLI_mempool_as_arrayN(BLI_mempool *pool, const char *allocstr) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
@ BLI_MEMPOOL_ALLOW_ITER
@ BLI_MEMPOOL_NOP
void void void BLI_mempool_set_memory_debug()
void BLI_mempool_free(BLI_mempool *pool, void *addr) 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
int BLI_mempool_len(const BLI_mempool *pool) ATTR_NONNULL(1)
void * BLI_mempool_findelem(BLI_mempool *pool, unsigned int index) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_mempool_calloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void BLI_mempool_destroy(BLI_mempool *pool) ATTR_NONNULL(1)
void BLI_mempool_clear(BLI_mempool *pool) ATTR_NONNULL(1)
void BLI_mempool_as_array(BLI_mempool *pool, void *data) ATTR_NONNULL(1
BMesh const char void * data
#define T
struct BLI_mempool_chunk * curchunk
Definition BLI_mempool.h:96
BLI_mempool * pool
Definition BLI_mempool.h:95
unsigned int curindex
Definition BLI_mempool.h:97
uint8_t flag
Definition wm_window.cc:145