Kernel heap for short-lived data.
More...
Kernel heap for short-lived data.
A heap apart from the kernel's own (see Kernel heap), for buffers that only live for the length of an operation. Where it is and what it costs is the platform's business: it may be memory that is only powered while something is allocated, so what is allocated here should be freed as soon as it is no longer needed, and nothing should be kept for long.
if (buf == NULL) {
return -ENOMEM;
}
prv_process(buf, len);
void * pbl_scratch_malloc(size_t size)
Allocate from the scratch heap.
void pbl_scratch_free(void *ptr)
Free memory allocated from the scratch heap.
◆ pbl_scratch_stats
Usage of the scratch heap.
| Data Fields |
|
unsigned int |
allocations |
Live allocations, 0 if not tracked. |
|
size_t |
max_free |
Largest block that can be allocated now. |
|
size_t |
peak |
Most bytes ever allocated at once, 0 if not tracked. |
|
size_t |
size |
Size of the heap, in bytes. |
|
size_t |
used |
Bytes allocated. |
◆ pbl_scratch_free()
| void pbl_scratch_free |
( |
void * |
ptr | ) |
|
Free memory allocated from the scratch heap.
- Parameters
-
◆ pbl_scratch_get_stats()
Get the usage of the scratch heap.
- Parameters
-
◆ pbl_scratch_malloc()
| void * pbl_scratch_malloc |
( |
size_t |
size | ) |
|
Allocate from the scratch heap.
The memory is aligned for any type. Not callable from interrupts.
- Parameters
-
- Returns
- The memory, or NULL if there is no room.
◆ pbl_scratch_zalloc()
| void * pbl_scratch_zalloc |
( |
size_t |
size | ) |
|
Allocate zeroed memory from the scratch heap.
- Parameters
-
- Returns
- The memory, or NULL if there is no room.
◆ pbl_scratch_zalloc_check()
| void * pbl_scratch_zalloc_check |
( |
size_t |
size | ) |
|
Allocate zeroed memory from the scratch heap, asserting on failure.
- Parameters
-
- Returns
- The memory.