memory array allocator
More...
memory array allocator
pseudo dynamic allocation in static memory arrays
- Author
- Tobias Heider heide.nosp@m.rt@n.nosp@m.m.ifi.nosp@m..lmu.nosp@m..de
◆ memarray_alloc()
Allocate memory chunk in memarray pool.
- Precondition
mem != NULL
- Note
- Allocated structure is not cleared before returned
- Parameters
-
[in,out] | mem | memarray pool to allocate block in |
- Returns
- pointer to allocated structure, if enough memory was available
-
NULL, on failure
◆ memarray_calloc()
Allocate and clear memory chunk in memarray pool.
- Precondition
mem != NULL
- Parameters
-
[in,out] | mem | memarray pool to allocate block in |
- Returns
- pointer to allocated structure, if enough memory was available
-
NULL, on failure
◆ memarray_free()
void memarray_free |
( |
memarray_t * |
mem, |
|
|
void * |
ptr |
|
) |
| |
Free memory chunk in memarray pool.
- Precondition
mem != NULL
-
ptr != NULL
- Parameters
-
[in,out] | mem | memarray pool to free block in |
[in] | ptr | pointer to memarray chunk |
◆ memarray_init()
void memarray_init |
( |
memarray_t * |
mem, |
|
|
void * |
data, |
|
|
size_t |
size, |
|
|
size_t |
num |
|
) |
| |
Initialize memarray pool with free list.
- Precondition
mem != NULL
-
data != NULL
-
size >= sizeof(void*)
-
num != 0
- Parameters
-
[in,out] | mem | memarray pool to initialize |
[in] | data | pointer to user-allocated data |
[in] | size | size of a single element in data |
[in] | num | number of elements in data |