Lines Matching full:blocks
3 Memory Blocks Allocator
6 The Memory Blocks Allocator allows memory blocks to be dynamically
9 * All memory blocks have a single fixed size.
11 * Multiple blocks can be allocated or freed at the same time.
13 * A group of blocks allocated together may not be contiguous.
16 * Bookkeeping of allocated blocks is done outside of the associated
27 Any number of Memory Blocks Allocator can be defined (limited only by
30 A memory blocks allocator has the following key properties:
35 * The **number of blocks** available for allocation.
38 * A **buffer** that provides the memory for the memory slab's blocks.
39 It must be at least "block size" times "number of blocks" bytes long.
41 * A **blocks bitmap** to keep track of which block has been allocated.
44 larger than 2 (i.e. 4, 8, 16, ...). To ensure that all memory blocks in
49 each memory blocks allocator must be declared and defined at compile time.
54 Each buffer associated with an allocator is an array of fixed-size blocks,
55 with no wasted space between the blocks.
57 The memory blocks allocator keeps track of unallocated blocks using
60 Memory Blocks Allocator
63 Internally, the memory blocks allocator uses a bitmap to keep track of
64 which blocks have been allocated. Each allocator, utilizing
65 the ``sys_bitarray`` interface, gets memory blocks one by one from
66 the backing buffer up to the requested number of blocks.
72 Multi Memory Blocks Allocator Group
75 The Multi Memory Blocks Allocator Group utility functions provide
84 To allocate memory blocks from group,
88 can be chosen. After an allocator is chosen, memory blocks are
91 Allocated memory blocks can be freed via
95 and then memory blocks are freed via :c:func:`sys_mem_blocks_free`.
100 Defining a Memory Blocks Allocator
103 A memory blocks allocator is defined using a variable of type
107 The following code defines and initializes a memory blocks allocator
108 which has 4 blocks that are 64 bytes long, each of which is aligned
115 Similarly, you can define a memory blocks allocator in private scope:
130 Allocating Memory Blocks
133 Memory blocks can be allocated by calling :c:func:`sys_mem_blocks_alloc`.
138 uintptr_t blocks[2];
140 ret = sys_mem_blocks_alloc(allocator, 2, blocks);
142 If ``ret == 0``, the array ``blocks`` will contain an array of memory
143 addresses pointing to the allocated blocks.
148 Memory blocks are released by calling :c:func:`sys_mem_blocks_free`.
150 The following code builds on the example above which allocates 2 memory blocks,
156 uintptr_t blocks[2];
158 ret = sys_mem_blocks_alloc(allocator, 2, blocks);
159 ... /* perform some operations on the allocated memory blocks */
160 ret = sys_mem_blocks_free(allocator, 2, blocks);
162 Using Multi Memory Blocks Allocator Group
183 To allocate and free memory blocks from the group:
188 uintptr_t blocks[1];
192 1, blocks, &blk_size);
194 ret = sys_multi_mem_blocks_free(&alloc_group, 1, blocks);