1 #ifndef __WILC_MEMORY_H__
2 #define __WILC_MEMORY_H__
6 * @brief Memory OS wrapper functionality
8 * @sa wilc_oswrapper.h top level OS wrapper file
13 #include <linux/types.h>
14 #include <linux/slab.h>
17 * @struct tstrWILC_MemoryAttrs
18 * @brief Memory API options
24 } tstrWILC_MemoryAttrs;
27 * @brief Allocates a given size of bytes
28 * @param[in] u32Size size of memory in bytes to be allocated
29 * @param[in] strAttrs Optional attributes, NULL for default
30 * if not NULL, pAllocationPool should point to the pool to use for
31 * this allocation. if NULL memory will be allocated directly from
33 * @param[in] pcFileName file name of the calling code for debugging
34 * @param[in] u32LineNo line number of the calling code for debugging
35 * @return The new allocated block, NULL if allocation fails
36 * @note It is recommended to use of of the wrapper macros instead of
37 * calling this function directly
38 * @sa sttrWILC_MemoryAttrs
47 void *WILC_MemoryAlloc(u32 u32Size, tstrWILC_MemoryAttrs *strAttrs,
48 char *pcFileName, u32 u32LineNo);
51 * @brief standrad malloc wrapper with custom attributes
53 #define WILC_MALLOC_EX(__size__, __attrs__) \
55 (__size__), __attrs__, NULL, 0))
58 * @brief Allocates a block (with custom attributes) of given type and number of
61 #define WILC_NEW_EX(__struct_type__, __n_structs__, __attrs__) \
62 ((__struct_type__ *)WILC_MALLOC_EX( \
63 sizeof(__struct_type__) * (u32)(__n_structs__), __attrs__))
66 * @brief standrad malloc wrapper with default attributes
68 #define WILC_MALLOC(__size__) \
69 WILC_MALLOC_EX(__size__, NULL)
75 * @brief Allocates a block (with default attributes) of given type and number of
78 #define WILC_NEW(__struct_type__, __n_structs__) \
79 WILC_NEW_EX(__struct_type__, __n_structs__, NULL)