38 lines
932 B
C
38 lines
932 B
C
#ifndef ETHERLIB_DYNMEM_H
|
|
#define ETHERLIB_DYNMEM_H
|
|
|
|
#include <stdint.h>
|
|
|
|
/**
|
|
* Initialize EtherLib dynamic memory management subsystem,
|
|
* based on heap pointer and size given in etherlib_options.h
|
|
*/
|
|
void dynmem_init();
|
|
|
|
/**
|
|
* Dynamically allocate memory from EtherLib's pool.
|
|
* @param size requested size
|
|
* @return pointer to allocated area or NULL on failure
|
|
*/
|
|
void * dynmem_alloc_(uint32_t size);
|
|
|
|
#ifdef DYNMEM_DEBUG
|
|
#define dynmem_alloc(size) dynmem_alloc_(size); MSG("ALLOC: %d %s() in %s:%d\n", size, __FUNCTION__, __FILE__, __LINE__)
|
|
#else
|
|
#define dynmem_alloc(size) dynmem_alloc_(size)
|
|
#endif
|
|
|
|
/**
|
|
* Release allocated block.
|
|
* @param ptr pointer to allocated area
|
|
*/
|
|
void dynmem_free_(void * ptr);
|
|
|
|
#ifdef DYNMEM_DEBUG
|
|
#define dynmem_free(ptr) MSG("FREE: %s() in %s:%d\n", __FUNCTION__, __FILE__, __LINE__), dynmem_free_(ptr)
|
|
#else
|
|
#define dynmem_free(ptr) dynmem_free_(ptr)
|
|
#endif
|
|
|
|
#endif //ETHERLIB_DYNMEM_H
|