memalloc.h

来自「用于WSN的PDA搜救器」· C头文件 代码 · 共 86 行

H
86
字号
/* Description : head for memory alloc functions.
 *
 * $Author: 王琢玉
 * $Date: 2007/02/23 
 * $Name:  memalloc.h
 */
 
#ifndef   MEMALLOC_H
#define   MEMALLOC_H


#include "pub_def.h"

#ifdef   MEMALLOC_GLOBALS
    #define   MEMALLOC_EXT
#else    
    #define   MEMALLOC_EXT   extern
#endif

/********************************************
Defines
********************************************/
#define    MEM_SIZE  1



/********************************************
Typedefs
********************************************/
typedef struct
{
    void *pNext;
    void *pPro;
}BIDIR_LINK;  //双向链表

/********************************************
 Globals
********************************************/
MEMALLOC_EXT   UINT8  Memory[MEM_SIZE][1024];

MEMALLOC_EXT   void   *pFreeMem[7];


/************************************************************
Function:    void  MemoryInit(void)

Parameter:

Return:   
             
Description: Init the memory
************************************************************/
void  MemoryInit(void);


/************************************************************
Function:    UINT8* MemoryAlloc(UINT16 size)

Parameter:   size     the size of memory want to alloc

Return:      UINT*    the pointer to the memory
             
Description: Apply for allocing memory  if fail,return NULL, 
             else ruturn the memory pointer
************************************************************/
UINT8* MemoryAlloc(UINT16 size);

/************************************************************
Function:    void FreeMemory(UINT8 *pfree)

Parameter:   *pfree     the pointer to the memory which wanted to free

Return:      
             
Description: free the memory that alloced before
************************************************************/
void FreeMemory(UINT8 *pfree);



#define   MemoryFree(p)     FreeMemory(p);  p = NULL;




#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?