| Description | | The _declare_box8 macro declares an array of bytes that can be used as a memory pool for allocation of fixed blocks with 8-byte alignment. The argument pool specifies the name of the memory pool variable that is used by the memory block allocation routines. The argument size specifies the size of the blocks, in bytes. The argument cnt specifies the number of blocks required in the memory pool. The _declare_box8 macro is part of RL-RTX. The definition is in rtl.h. - The macro rounds up the value of size to the next multiple of 8 to give the blocks an 8-byte alignment.
- The macro also declares an additional 16 bytes at the start of the memory pool to store internal pointers and size information about the memory pool.
|
| Example | |
#include <rtl.h>
/* Reserve a memory for 25 blocks of 30-bytes. */
_declare_box8(mpool,30,25);
void membox_test (void) {
U8 *box;
U8 *cbox;
_init_box8 (mpool, sizeof (mpool), 30);
box = _alloc_box (mpool);
/* This block is initialized to 0. */
cbox = _calloc_box (mpool);
/* 'box' and 'cbox' are always 8-byte aligned. */
.
.
_free_box (mpool, box);
_free_box (mpool, cbox);
}
|