📄 isemem.h
字号:
/********************************************************************
isemem.h
----------------------------------------------------------------
软件许可证 - 公有域软件
版权所有 (C) 2001 VCHelp coPathway ISee workgroup.
----------------------------------------------------------------
本文件用途: 内存防护系统定义文件
本文件编写人:
YZ yzfree##yeah.net
本文件版本: 20501
最后修改于: 2002-5-1
注:以上E-Mail地址中的##请用@替换。
----------------------------------------------------------------
修正历史:
2002-5 第一个测试版
********************************************************************/
#ifndef __ISEE_MEMSYS_INC__
#define __ISEE_MEMSYS_INC__
#ifdef WIN32 /* Windows */
/* 如果你想将本系统用于其它语言,可将其编译为DLL。那样的话请启用
* 下面的编译选项(注:DLL的项目名必须为isemem)
# ifdef ISEMEM_EXPORTS
# define ISEMEM_API __declspec(dllexport)
# else
# define ISEMEM_API __declspec(dllimport)
# endif
*/
# define ISEMEM_API
# define CALLAGREEMENT __cdecl
/* 用于存储防护系统自身数据的堆函数接口 */
# define _create_heap() ise_heap = HeapCreate(0, 102400, 0)
# define _alloc_heap(size) HeapAlloc(ise_heap, 0, size)
# define _realloc_heap(p, size) HeapReAlloc(ise_heap, 0, p, size)
# define _free_heap(p) HeapFree(ise_heap, 0, p)
# define _destroy_heap() HeapDestroy(ise_heap)
#else /* Linux 平台的相应代码可以在下面填写 */
# define ISEMEM_API
# ifndef NDEBUG
# define _DEUBG
# endif
# define _create_heap()
# define _alloc_heap(size)
# define _realloc_heap(p, size)
# define _free_heap(p)
# define _destroy_heap()
typedef try __try
typedef finally __finally
typedef leave __leave
typedef except __except
#endif /*WIN32*/
/* 所有的防护代码只有在调试模式下才会有效 */
#ifdef _DEBUG
struct _tag_memblock_info;
typedef struct _tag_memblock_info ISE_MBINFO;
typedef struct _tag_memblock_info *LPISE_MBINFO;
#define ISE_MEMBLOCK_MARK ((unsigned long)0x65657369) /* 内存块首、尾缓冲区标志("isee")*/
#define ISE_MB_FILL_BYTE ((unsigned char)0xcc) /* 内存废料填充值 */
/* 内存信息块结构 */
struct _tag_memblock_info
{
unsigned long tag0; /* 头标签 */
LPISE_MBINFO prev; /* 前一个信息块 */
LPISE_MBINFO next; /* 后一个信息块 */
unsigned char *pbegin; /* 总内存块首地址(即内存块头标志地址)*/
unsigned char *pstart; /* 用户内存块首地址 */
long total_len; /* 总长度,包括内存块头标志和尾标志的长度 */
long use_len; /* 用户申请的内存长度 */
unsigned long useflag; /* 使用标志 */
long rev[14]; /* 保留 */
long linenum; /* 分配语句在代码文件中的行号 */
char filename[160]; /* 分配内存块的代码文件名(全名) */
unsigned long tag1; /* 尾标签 */
};
#if (defined(__cplusplus) || defined(c_plusplus))
extern "C" {
#endif
/* 定义错误及警告信息的输出函数 */
#if defined(_MSC_VER)
#define ISE_PUTERR_STR(str) OutputDebugStringA(str)
#else
#define ISE_PUTERR_STR(str) fprintf(stderr, (const char *)str)
#endif
/* 当防护系统发现问题时采取的动作。 0-让计算机发出BEEP声后继续运行程序。
1-用断言断掉程序 */
#define INFORM_LEVEL 0
#if defined(WIN32)
#define inform_me(bol) ((bol == 0) ? Beep(400, 100) : assert(0))
#else
#define inform_me(bol) assert(0)
#endif
ISEMEM_API void * CALLAGREEMENT _ise_realloc(void **, long, const char *, int);
ISEMEM_API void CALLAGREEMENT _ise_free(void *);
ISEMEM_API void * CALLAGREEMENT _ise_malloc(long, const char *, int);
ISEMEM_API void CALLAGREEMENT _ise_help_me_sure(void *, int, char *, int);
ISEMEM_API void CALLAGREEMENT _ise_check_pointer(void *, char *, int);
/* 内存防护系统的接口函数 */
ISEMEM_API void CALLAGREEMENT ise_open_mem_sys(void);
ISEMEM_API int CALLAGREEMENT ise_close_mem_sys(void);
ISEMEM_API int CALLAGREEMENT ise_get_mb_count(void);
ISEMEM_API void CALLAGREEMENT ise_check_mem_sys(void);
ISEMEM_API void CALLAGREEMENT ise_put_pointer_info(void *, char *);
#define ise_help_me_sure(p, size) _ise_help_me_sure((p), (size), __FILE__, __LINE__)
#define ise_check_pointer(p) _ise_check_pointer((p), __FILE__, __LINE__)
#define ise_malloc(size) _ise_malloc((size), __FILE__, __LINE__)
#define ise_free(p) _ise_free((p));
#define ise_realloc(pp, newsize) _ise_realloc((pp), (newsize), __FILE__, __LINE__)
#if (defined(__cplusplus) || defined(c_plusplus))
}
#endif
#else /* 发布状态下所有的防护代码都将被去除 */
#define ise_open_mem_sys() ((void)0)
#define ise_close_mem_sys() ((void)0)
#define ise_check_mem_sys() ((void)0)
#define ise_get_mb_count() ((void)0)
#define ise_put_pointer_info(p,buf) ((void)0)
#define ise_help_me_sure(p,size) ((void)0)
#define ise_check_pointer(p) ((void)0)
#define ise_realloc(pp, newsize) realloc((pp), (newsize))
#define ise_free(p) free((p));
#define ise_malloc(size) malloc((size))
#endif /* _DEBUG */
#endif //__ISEE_MEMSYS_INC__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -