Files
chat_rebot-connect-with-one…/c/memctl/memctl.h

36 lines
747 B
C

#ifndef MEMCTL
#define MEMCTL
#include "config.h"
#include <stdatomic.h>
#define 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;//内存不足指示器
//获取一个内存块
mem_block* (*GetBlock)(struct mem_ctl*,int);
//释放一个内存块
int (*FreeBlock)(struct memctl*,mem_block*);
}mem_ctl;
int init_memctl(mem_ctl *self);
int free_memctl(mem_ctl *self);
#endif