加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
md.h 1.50 KB
一键复制 编辑 原始数据 按行查看 历史
luanhailiang 提交于 2012-08-09 20:44 . My mudos
/* used by md.c (the malloc debug module) */
#if defined(CHECK_MEMORY) && !defined(DEBUGMALLOC_EXTENSIONS)
#undef CHECK_MEMORY
#endif
typedef struct md_node_s {
int size;
struct md_node_s *next;
#ifdef DEBUGMALLOC_EXTENSIONS
int id;
int tag;
char *desc;
#endif
#ifdef CHECK_MEMORY
int magic;
#endif
} md_node_t;
#ifdef CHECK_MEMORY
#define MD_OVERHEAD (sizeof(md_node_t) + sizeof(int))
#define MD_MAGIC 0x4bee4bee
void check_all_blocks PROT((int));
#else
#define MD_OVERHEAD (sizeof(md_node_t))
#endif
#define MD_TABLE_BITS 14
#define MD_TABLE_SIZE (1 << MD_TABLE_BITS)
#define MD_HASH(x) (((unsigned int)x >> 3) & (MD_TABLE_SIZE - 1))
#define PTR(x) ((void *)(x + 1))
#define NODET_TO_PTR(x, y) ((y)(x + 1))
#define PTR_TO_NODET(x) ((md_node_t *)(x) - 1)
#define DO_MARK(ptr, kind) if (PTR_TO_NODET(ptr)->tag != kind) \
fprintf(stderr, "Expected node of type %04x: got %s %04x\n", \
kind, PTR_TO_NODET(ptr)->desc, PTR_TO_NODET(ptr)->tag); \
else PTR_TO_NODET(ptr)->tag |= TAG_MARKED
#ifdef DEBUGMALLOC_EXTENSIONS
#define SET_TAG(x, y) set_tag(x, y)
#else
#define SET_TAG(x, y)
#endif
extern int malloc_mask;
extern unsigned int total_malloced;
extern unsigned int hiwater;
void MDinit PROT((void));
void MDmalloc PROT((md_node_t *, int, int, char *));
int MDfree PROT((void *));
#ifdef DEBUGMALLOC_EXTENSIONS
struct svalue_s;
void mark_svalue PROT((struct svalue_s *));
void set_tag PROT((void *, int));
void check_string_stats PROT((outbuffer_t *));
#endif
#define MAX_CATEGORY 130
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化