36 lines
744 B
C
36 lines
744 B
C
#ifndef MEMCTL
|
|
#define MEMCTL
|
|
#include "config.h"
|
|
#include <stdatomic.h>
|
|
|
|
#define MEM_FREE 1
|
|
#define INUSE -1
|
|
#define PROCESSING 0
|
|
|
|
#define LOGMOD 0
|
|
#define COMMENMOD 1
|
|
|
|
typedef struct mem_block
|
|
{
|
|
void *location;//块地址
|
|
atomic_int condition;//块状态
|
|
}mem_block;
|
|
|
|
typedef struct mem_ctl
|
|
{
|
|
mem_block blocks[MAX_MEM_SIZE];
|
|
atomic_int logbuf;
|
|
atomic_int poolsize;
|
|
atomic_int Commenlast_loc;//分配起始
|
|
atomic_int Loglast_loc;
|
|
atomic_int mem_e_indicator;//内存不足指示器
|
|
//获取一个内存块
|
|
void** (*GetBlock)(struct mem_ctl*,int);
|
|
//释放一个内存块
|
|
int (*FreeBlock)(struct mem_ctl*,void**);
|
|
}mem_ctl;
|
|
|
|
int init_memctl(mem_ctl *self);
|
|
int free_memctl(mem_ctl *self);
|
|
|
|
#endif |