Blender  V3.3
BLI_memblock.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2008 Blender Foundation. All rights reserved. */
3 
4 #pragma once
5 
10 #include "BLI_compiler_attrs.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #define BLI_MEM_BLOCK_CHUNK_SIZE (1 << 15) /* 32KiB */
17 
18 struct BLI_memblock;
19 
20 typedef struct BLI_memblock BLI_memblock;
21 typedef void (*MemblockValFreeFP)(void *val);
22 
31 
32 #define BLI_memblock_create(elem_size) BLI_memblock_create_ex(elem_size, BLI_MEM_BLOCK_CHUNK_SIZE)
33 
34 typedef struct BLI_memblock_iter {
35  void **chunk_list;
36  int cur_index;
37  int end_index;
39  int chunk_idx;
40  int elem_size;
41  int elem_ofs;
43 
46 
52 void *BLI_memblock_elem_get(BLI_memblock *mblk, int chunk, int elem) ATTR_WARN_UNUSED_RESULT
53  ATTR_NONNULL();
54 
55 #ifdef __cplusplus
56 }
57 #endif
#define ATTR_WARN_UNUSED_RESULT
#define ATTR_NONNULL(...)
void(* MemblockValFreeFP)(void *val)
Definition: BLI_memblock.h:21
void BLI_memblock_destroy(BLI_memblock *mblk, MemblockValFreeFP free_callback) ATTR_NONNULL(1)
Definition: BLI_memblock.c:66
void * BLI_memblock_elem_get(BLI_memblock *mblk, int chunk, int elem) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: BLI_memblock.c:176
struct BLI_memblock_iter BLI_memblock_iter
void BLI_memblock_iternew(BLI_memblock *mblk, BLI_memblock_iter *iter) ATTR_NONNULL()
Definition: BLI_memblock.c:145
BLI_memblock * BLI_memblock_create_ex(uint elem_size, uint chunk_size) ATTR_WARN_UNUSED_RESULT
Definition: BLI_memblock.c:47
void * BLI_memblock_iterstep(BLI_memblock_iter *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: BLI_memblock.c:157
void * BLI_memblock_alloc(BLI_memblock *mblk) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition: BLI_memblock.c:115
void BLI_memblock_clear(BLI_memblock *mblk, MemblockValFreeFP free_callback) ATTR_NONNULL(1)
Definition: BLI_memblock.c:86
unsigned int uint
Definition: BLI_sys_types.h:67
SyclQueue void void size_t num_bytes void
static const int chunk_size