www.pudn.com > ASM86_64.rar > balloc.h
#ifndef _BALLOC_H_
#define _BALLOC_H_
typedef struct mem_link_struct {
unsigned int size;
void *head_ptr;
void *tail_ptr;
unsigned char used; /* is used ? */
struct mem_link_struct *next, *prev;
} mem_link_t;
typedef struct alloc_heap_struct {
unsigned int total_size;
unsigned int free_size;
mem_link_t *free_link;
mem_link_t *used_link;
void *heap;
} alloc_heap_t;
typedef unsigned int memlink_size_t;
/* free-heap-link total value type, it's a 32-bit type */
typedef unsigned int free_link_size_t;
/* used-heap-link total value type, it's a 32-bit type */
typedef unsigned int used_link_size_t;
/* default user-program buffer pool 64K */
#define POOLSIZE 65536
#define LINKSIZE 256
#define FREELINKSIZE 256
#define USEDLINKSIZE 256
#define EOK 0
#define EINIT -1
#define EFULLNESS -2
#define ENOMEM -3
#define EERROR -4
/*
char *e_msg[] = {
"initialize error",
"the buffer pool fullness",
"the buffer pool not enough",
0
};
*/
int init_bheap(unsigned int size, void *ptr);
void *balloc(unsigned int size);
int bfree(void *ptr);
#endif