4G_module/include/cmiot/cm_mem.h

131 lines
3.1 KiB
C
Raw Permalink Normal View History

2024-09-02 17:54:29 +08:00
/**
* @file cm_mem.h
* @brief
* @copyright Copyright © 2021 China Mobile IOT. All rights reserved.
* @author By ljw
* @date 2021/05/28
*
* @defgroup mem mem
* @ingroup SYS
* @{
*/
#ifndef __CM_MEM_H__
#define __CM_MEM_H__
/****************************************************************************
* Included Files
****************************************************************************/
#include "stdint.h"
#include "stddef.h"
/**
* @ingroup cm_mem
* @{
*/
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/** heap状态 */
typedef struct{
uint32_t total_size; /*!< 总量大小 */
uint32_t allocated; /*!< 目前已分配大小 */
uint32_t free; /*!< 剩余可分配大小 */
uint32_t max_continuity_free; /*!< 本平台无效 */
uint32_t allocated_peak; /*!< 本平台无效 */
uint32_t allocated_times; /*!< 本平台无效 */
uint32_t free_times; /*!< 本平台无效 */
} cm_heap_stats_t;
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/**
* @brief heap状态
*
* @param [out] stats heap状态
*
* @return
* = 0 - \n
* < 0 - ,
*
* @details MemPool信息
*/
int32_t cm_mem_get_heap_stats(cm_heap_stats_t *stats);
/**
* @brief
*
* @param [in] size
*
* @return
*
* @details 使C库接口
*/
void *cm_malloc(size_t size);
/**
* @brief
*
* @param [in] ptr
* @param [in] size
*
* @return
*
* @details 使C库接口
*/
void *cm_realloc(void *ptr, size_t size);
/**
* @brief
*
* @param [in] nitems
* @param [in] size
*
* @return
*
* @details 使C库接口
*/
void *cm_calloc(size_t nitems, size_t size);
/**
* @brief
*
* @param [in] buf
*
* @return
*
* @details 使C库接口
*/
void cm_free(void *ptr);
#undef EXTERN
#ifdef __cplusplus
}
#endif
/** @}*/
#endif /* __CM_MEM_H__ */