mem.h

来自「ARP协议,含ARP」· C头文件 代码 · 共 41 行

H
41
字号

#ifndef _MEM_H_
#define _MEM_H_

#include "typedef.h"
#include "string.h"
//BLOCK SIZE必须是偶数,为了计算TCPIP的校验和
#define MEM_BLK_SIZE                300
#define MEM_BLK_NUM                 7

#define MEM_HEAD_SIZE               4
#define PMEM_BLOCK(p)               ((struct _mem_block *)(((uc*)(p)) - MEM_HEAD_SIZE))

struct _mem_block {
    struct _mem_block *pnext;
    us len;
    uc content[MEM_BLK_SIZE];
};

extern struct _mem_block *mb_head;

void* alloc_mem (us len);
void free_mem (void *p);
void* alloc_mb (void);
void free_mb (struct _mem_block *p);
bool chk_mem (struct _mem_block *p);
void free_msg (struct _mem_block *p);

void copy_to_buf (struct _mem_block *pm, us start, uc *buf, us len);
void copy_from_buf (struct _mem_block *p, us start, uc *buf, us len);

void *make_list_msg (us len);
us get_msg_len (struct _mem_block *p);

void print_msg (char ch, struct _mem_block *pm);
void print_msg_len (char ch, struct _mem_block *pm);

void init_mem(void);

#endif

⌨️ 快捷键说明

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