/****************************************************************************** * file include/memory.h * author YuLiang * version 1.0.0 * date 10-Sep-2021 * brief This file provides all the headers of the memory functions. ****************************************************************************** * Attention * *

© COPYRIGHT(c) 2021 LandPower

* * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of LandPower nor the names of its contributors may be used to * endorse or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ******************************************************************************/ #ifndef _MEMORY_H_ #define _MEMORY_H_ /* Includes ------------------------------------------------------------------*/ #define MTYPE_MEMSTR_LEN 20 /* Define --------------------------------------------------------------------*/ enum { MTYPE_CLI = 1, MTYPE_BUF, MTYPE_BUF_DATA, MTYPE_BUF_TMP, MTYPE_VTY, MTYPE_VTY_TMP, MTYPE_VTY_OUT_BUF, MTYPE_VTY_HIST, MTYPE_LOG, MTYPE_PREFIX, MTYPE_THREAD_MONITOR, MTYPE_MTIMER, MTYPE_HASH, MTYPE_HASH_BACKET, MTYPE_HASH_INDEX, MTYPE_THREAD, MTYPE_THREAD_STATS, MTYPE_THREAD_MASTER, MTYPE_THREAD_FUNCNAME, MTYPE_FIFO, MTYPE_GPIO, MTYPE_RECV, MTYPE_SENT, MTYPE_USART, MTYPE_ETH, MTYPE_GIS, MTYPE_DAU, MTYPE_CSG, MTYPE_STORAGE, MTYPE_DEBUG, MTYPE_MAX, }; /* Exported types ------------------------------------------------------------*/ /* For pretty printing of memory allocate information. */ typedef struct _mem_node { int32_t index; const char *format; } mem_node_t; typedef struct _mem_list { mem_node_t *nodes; const char *name; } mem_list_t; /* Exported macro ------------------------------------------------------------*/ #define XMALLOC(mtype, size) \ mtype_x_malloc (__FILE__, __LINE__, (mtype), (size)) #define XMALLOC_Q(mtype, size) \ mtype_x_malloc_q (__FILE__, __LINE__, (mtype), (size)) #define XCALLOC(mtype, size) \ mtype_x_calloc (__FILE__, __LINE__, (mtype), (size)) #define XREALLOC(mtype, ptr, size) \ mtype_x_realloc (__FILE__, __LINE__, (mtype), (ptr), (size)) #define XFREE(mtype, ptr) \ do { \ mtype_x_free (__FILE__, __LINE__, (mtype), (ptr)); \ ptr = NULL; } \ while (0) #define XSTRDUP(mtype, str) \ mtype_x_strdup (__FILE__, __LINE__, (mtype), (str)) /* Extern global variables ---------------------------------------------------*/ /* Extern functions ----------------------------------------------------------*/ extern void *mtype_x_malloc(const char *file, int32_t line, int32_t type, size_t size); extern void *mtype_x_malloc_q(const char *file, int32_t line, int32_t type, size_t size); extern void *mtype_x_calloc(const char *file, int32_t line, int32_t type, size_t size); extern void *mtype_x_realloc(const char *file, int32_t line, int32_t type, void *ptr, size_t size); extern void mtype_x_free(const char *file, int32_t line, int32_t type, void *ptr); extern char *mtype_x_strdup(const char *file, int32_t line, int32_t type, const char *str); extern void mtype_init(void); extern void mtype_init_befor(void); #endif /************************ (C) COPYRIGHT LandPower ***** END OF FILE ****************/