2 * \addtogroup exampleapps
\r
8 * Memory block allocation routines.
\r
9 * \author Adam Dunkels <adam@sics.se>
\r
17 * Declare a memory block.
\r
19 * \param name The name of the memory block (later used with
\r
20 * memb_init(), memb_alloc() and memb_free()).
\r
22 * \param size The size of each memory chunk, in bytes.
\r
24 * \param num The total number of memory chunks in the block.
\r
27 #define MEMB(name, size, num) \
\r
28 static char memb_mem[(size + 1) * num]; \
\r
29 static struct memb_blocks name = {size, num, memb_mem}
\r
31 struct memb_blocks {
\r
32 unsigned short size;
\r
37 void memb_init(struct memb_blocks *m);
\r
38 char *memb_alloc(struct memb_blocks *m);
\r
39 char memb_ref(struct memb_blocks *m, char *ptr);
\r
40 char memb_free(struct memb_blocks *m, char *ptr);
\r
43 #endif /* __MEMB_H__ */
\r