12345678910111213141516171819202122232425262728293031 |
- /**
- * @file tool_memory.h
- * @brief 实现内存管理相关的函数
- * This file implements routines for memory management.
- * @version 0.1
- * @date 2021-09-17
- *
- * @copyright Copyright (c) 2021
- *
- */
- #ifndef __TOOL_MEMORY_H__
- #define __TOOL_MEMORY_H__
- #include "csocp_config.h"
- /** 分配内存 Allocate memory */
- void c_mem_create(void **p_ptr, /**< 指针:指向输入数据 Pointer to input data */
- c_int size, /**< 分配内存大小 Size of allocated memory */
- c_int ifzero /**< 是否用0初始化 Whether to initialize by zeros */
- );
- /** 释放内存 Free memory */
- void c_mem_free(void **p_ptr /**< 指针:指向输入数据 Pointer to input data */
- );
- #define CSOCP_INIT(ptr, num) c_mem_create((void **)&(ptr), sizeof(*(ptr)) * (num), 0)
- #define CSOCP_INITZ(ptr, num) c_mem_create((void **)&(ptr), sizeof(*(ptr)) * (num), 1)
- #define CSOCP_FREE(ptr) c_mem_free((void **)&(ptr))
- #endif
|