📄 xmem.h
字号:
#endif
#define XMEM_FILE 0 /* disable feature to avoid conflicts with XFILE package */
#else
#ifndef XMEM_FILE
#define XMEM_FILE 1 /* default 1: trace fgets(), fread(), ... */
#endif
#endif
#ifndef XMEM_STREOS
#define XMEM_STREOS 0 /* default 0: do not test for "end-of-string" (EOS, '\0') within range */
#endif /* useful to test strings */
#ifndef XMEM_STATS
#define XMEM_STATS 1 /* default 1: statistical information */
#endif
#ifndef XMEM_PEDANTIC
#define XMEM_PEDANTIC 0 /* default 0: no pedantic checking of all pointers */
#endif
#ifndef XMEM_LOGFILE /* write activity to logfile */
#define XMEM_LOGFILE 0 /* default 0: no logfile */
#endif
#if XMEM_LOGFILE
#ifndef XMEM_HTMLLOGFILE /* write activity to HTML logfile */
#define XMEM_HTMLLOGFILE 1 /* default 1: HTML logfile */
#endif
#else
#define XMEM_HTMLLOGFILE 0 /* default 0: no HTML logfile */
#endif
#ifndef XMEM_ERRLOGFILE /* write error messages to logfile */
#define XMEM_ERRLOGFILE 0 /* default 0: no error logfile */
#endif
#ifndef XMEM_SETTINGS /* display and write XMEM settings to logfile */
#define XMEM_SETTINGS 1 /* default 1: XMEM settings */
#endif
#ifndef XMEM_CALLTRACE /* write extensive call trace report with calling parameters and return values */
#define XMEM_CALLTRACE 0 /* default 0: no call tracing */
#endif
#ifndef XMEM_TEST_MCB
#define XMEM_TEST_MCB 1 /* default 1: test Memory Control Block (MCB) size */
#endif /* actually only MS-C/C++ and Borland C, otherwise not possible/unknown */
#ifndef XMEM_STRESS
#define XMEM_STRESS 0 /* default 0: do not perform allocation stress testing */
#endif
#if _WIN32
#ifndef XMEM_OUTPUTDEBUGSTRING
#define XMEM_OUTPUTDEBUGSTRING 0 /* default 0: do not write to debug output */
#endif
#else
#ifdef XMEM_OUTPUTDEBUGSTRING
#undef XMEM_OUTPUTDEBUGSTRING
#endif
#define XMEM_OUTPUTDEBUGSTRING 0 /* default 0: do not write to debug output */
#endif
#if _WIN32
#ifndef XMEM_DIALOG
#define XMEM_DIALOG 0 /* default 0: do not display dialog box */
#define XMEM_DIALOG_SHOW 0
#else
#if XMEM_DIALOG
#define XMEM_DIALOG_SHOW 1
#endif
#endif
#else
#ifdef XMEM_DIALOG
#undef XMEM_DIALOG
#endif
#define XMEM_DIALOG 0 /* default 0: do not display dialog box */
#ifdef XMEM_DIALOG_SHOW
#undef XMEM_DIALOG_SHOW
#endif
#define XMEM_DIALOG_SHOW 0
#endif
#if _WIN32 /* if WIN32 */
#ifndef XMEM_BROWSER /* XMEM_BROWSER undefined */
#define XMEM_BROWSER 0 /* default 0: do not use XMEM Browser */
#else
#if XMEM_BROWSER /* XMEM_BROWSER enabled */
#if !XMEM_DIALOG
#undef XMEM_DIALOG
#define XMEM_DIALOG 1
#undef XMEM_DIALOG_SHOW
#define XMEM_DIALOG_SHOW 0
#ifdef __XMEM__
#pragma message(">>> XMEM_DIALOG enabled due to XMEM_BROWSER!!!")
#endif
#endif
#if !XMEM_LOGFILE
#undef XMEM_LOGFILE
#define XMEM_LOGFILE 1
#ifdef __XMEM__
#pragma message(">>> XMEM_LOGFILE enabled due to XMEM_BROWSER!!!")
#endif
#endif
#endif
#endif /* XMEM_BROWSER */
#else /* else not WIN32 */
#ifdef XMEM_BROWSER
#undef XMEM_BROWSER
#endif
#define XMEM_BROWSER 0
#endif /* end if WIN32 */
/*****************************************************************************/
/**** handle XMEM_QUIET mode: disable defines ****/
/*****************************************************************************/
/**** if there is no output, most of the tests can be switched off ****/
#if XMEM_QUIET && !XMEM_FORCE_OUTPUT
#ifdef XMEM_VISIT
#undef XMEM_VISIT
#endif
#ifdef XMEM_FREENULL
#undef XMEM_FREENULL
#endif
#ifdef XMEM_WITHIN
#undef XMEM_WITHIN
#endif
#ifdef XMEM_GUARD
#undef XMEM_GUARD
#endif
#ifdef XMEM_ALLOCFILL
#undef XMEM_ALLOCFILL
#endif
#ifdef XMEM_FREEFILL
#undef XMEM_FREEFILL
#endif
#ifdef XMEM_USED
#undef XMEM_USED
#endif
#ifdef XMEM_ALLOC_FAIL_WARN
#undef XMEM_ALLOC_FAIL_WARN
#endif
#ifdef XMEM_WARN_BAD
#undef XMEM_WARN_BAD
#endif
#ifdef XMEM_ALLOCA
#undef XMEM_ALLOCA
#endif
#ifdef XMEM_STR
#undef XMEM_STR
#endif
#ifdef XMEM_MEM
#undef XMEM_MEM
#endif
#ifdef XMEM_FILE
#undef XMEM_FILE
#endif
#ifdef XMEM_STREOS
#undef XMEM_STREOS
#endif
#ifdef XMEM_STATS
#undef XMEM_STATS
#endif
#ifdef XMEM_PEDANTIC
#undef XMEM_PEDANTIC
#endif
#ifdef XMEM_LOGFILE
#undef XMEM_LOGFILE
#endif
#ifdef XMEM_ERRLOGFILE
#undef XMEM_ERRLOGFILE
#endif
#ifdef XMEM_CALLTRACE
#undef XMEM_CALLTRACE
#endif
#ifdef XMEM_TEST_MCB
#undef XMEM_TEST_MCB
#endif
#ifdef XMEM_STRESS
#undef XMEM_STRESS
#endif
#ifdef XMEM_DIALOG
#undef XMEM_DIALOG
#endif
#endif
/**** macros to enable storing of allocation location ****/
#if __GNUC__
#define _FUNC_ __FUNCTION__ /* or __PRETTY_FUNCTION__ ? */
#elif defined(_MSC_VER) && (_MSC_VER >= 1300)
#define _FUNC_ __FUNCTION__ /* available since MS Visual C++ 7.0 */
#else
#define _FUNC_ "?" /* dummy */
#endif
#define FUNCTION_UNKNOWN "?"
#define FILENAME_UNKNOWN "?"
#if XMEM_WHERE /**** trace allocation call location ****/
#define _WHERE(x,y,z) ,x,y,z
#define _CPP_WHERE(x,y,z) (x,y,z)
#else /**** no trace allocation call location ****/
#define _WHERE(x,y,z) /* nothing */
#define _CPP_WHERE(x,y,z) /* nothing */
#endif
/**** macros related to alloca() handling ****/
#if XMEM_ALLOCA /**** only for MSC and GNU ****/
#if defined(_MSC_VER)
#ifdef alloca
#undef alloca
#endif
#define os_alloca _alloca
#elif __GNUC__
#ifdef alloca
#undef alloca
#endif
#define os_alloca alloca
#endif
#endif
/*****************************************************************************/
/* function prototypes */
/*****************************************************************************/
#if XMEM_C_INTERFACE /******** C interface (for C++) otherwise pure C++ functions ********/
#ifdef __cplusplus
extern "C" {
#endif
#endif
/**** XMEM specific functions ****/
void xmem_showstatus(const char *, const char *, unsigned long); /* show status report */
void xmem_check_free(const char *, const char *, unsigned long); /* check pointers and free them */
void xmem_check_free_virtual(unsigned int, const char *, const char *, unsigned long); /* check pointers but do not free them */
void xmem_check_ptr(void *, const char *, const char *, unsigned long); /* check specific pointer */
void xmem_overwrite(const char *, const char *, unsigned long);
int xmem_location(const char *, const char *, unsigned long);
void xmem_before_delete(const char *, const char *, unsigned long);
void xmem_after_delete(void);
void xmem_set_memtrace(unsigned int, const char *, const char *, unsigned long); /* set type of memory trace */
void xmem_enable_memtrace(const char *, const char *, unsigned long); /* enable tracing */
void xmem_disable_memtrace(const char *, const char *, unsigned long);
unsigned long xmem_get_alloc_nr(const char *, const char *, unsigned long);
void xmem_set_trace_alloc(unsigned long, const char *, const char *, unsigned long); /* set alloc trace to # */
void xmem_reset_trace_alloc(const char *, const char *, unsigned long);
void xmem_set_trace_free(unsigned long, const char *, const char *, unsigned long); /* set free trace to # */
void xmem_reset_trace_free(const char *, const char *, unsigned long);
void xmem_set_max_heapsize(size_t, const char *, const char *, unsigned long);/* set heap size limit */
size_t xmem_get_max_heapsize(const char *, const char *, unsigned long);
void xmem_set_stress_ratio(unsigned int, const char *, const char *, unsigned long); /* set alloc fail level */
unsigned int xmem_get_stress_ratio(const char *, const char *, unsigned long);
#if _WIN32
void xmem_set_output_function(void (__stdcall *)(const char *), const char *, const char *, unsigned long);
#endif
size_t xmem_get_overhead(const char *, const char *, unsigned long);
void xmem_enable_print(const char *, const char *, unsigned long); /* enable print */
void xmem_disable_print(const char *, const char *, unsigned long);
void xmem_enable_log(const char *, const char *, unsigned long); /* enable log file writing */
void xmem_disable_log(const char *, const char *, unsigned long);
void xmem_message(const char *, const char *, const char *, unsigned long);
void xmem_enter_scope(const char *, const char *, unsigned long); /* enter scope # */
void xmem_leave_scope(const char *, const char *, unsigned long); /* leave scope # */
/**** memory allocation and memory/string/stream handling functions ****/
void *xmem_malloc(size_t _WHERE(const char *, const char *, unsigned long));
void *xmem_calloc(size_t, size_t _WHERE(const char *, const char *, unsigned long));
void *xmem_realloc(void *, size_t _WHERE(const char *, const char *, unsigned long));
void *xmem_alloca(void *, size_t _WHERE(const char *, const char *, unsigned long));
void *xmem_xmalloc(size_t _WHERE(const char *, const char *, unsigned long));
void *xmem_xcalloc(size_t, size_t _WHERE(const char *, const char *, unsigned long));
void *xmem_xrealloc(void *, size_t _WHERE(const char *, const char *, unsigned long));
#if defined(_MSC_VER)
void *xmem_expand(void *, size_t _WHERE(const char *, const char *, unsigned long));
#endif
void xmem_free(void * _WHERE(const char *, const char *, unsigned long));
void xmem_cfree(void * _WHERE(const char *, const char *, unsigned long));
void xmem_xfree(void * _WHERE(const char *, const char *, unsigned long));
char *xmem_strcat(char *, const char * _WHERE(const char *, const char *, unsigned long));
char *xmem_strncat(char *, const char *, size_t _WHERE(const char *, const char *, unsigned long));
char *xmem_strchr(const char *, int _WHERE(const char *, const char *, unsigned long));
int xmem_strcmp(const char *, const char * _WHERE(const char *, const char *, unsigned long));
int xmem_strcmpi(const char *, const char * _WHERE(const char *, const char *, unsigned long));
int xmem_stricmp(const char *, const char * _WHERE(const char *, const char *, unsigned long));
char *xmem_strcpy(char *, const char * _WHERE(const char *, const char *, unsigned long));
char *xmem_strdup(const char * _WHERE(const char *, const char *, unsigned long));
size_t xmem_strlen(const char * _WHERE(const char *, const char *, unsigned long));
size_t xmem_strnlen(const char *, size_t _WHERE(const char *, const char *, unsigned long));
#ifndef __linux__
char *xmem_strlwr(char * _WHERE(const char *, const char *, unsigned long));
#endif
int xmem_strncmp(const char *, const char *, size_t _WHERE(const char *, const char *, unsigned long));
#ifndef __linux__
int xmem_strnicmp(const char *, const char *, size_t _WHERE(const char *, const char *, unsigned long));
#endif
char *xmem_strncpy(char *, const char *, size_t _WHERE(const char *, const char *, unsigned long));
char *xmem_strrchr(const char *, int _WHERE(const char *, const char *, unsigned long));
char *xmem_strrev(char * _WHERE(const char *, const char *, unsigned long));
char *xmem_strset(char *, int _WHERE(const char *, const char *, unsigned long));
char *xmem_strnset(char *, int, size_t _WHERE(const char *, const char *, unsigned long));
char *xmem_strstr(const char *, const char * _WHERE(const char *, const char *, unsigned long));
char *xmem_strtok(char *, const char * _WHERE(const char *, const char *, unsigned long));
#ifndef __linux__
char *xmem_strupr(char * _WHERE(const char *, const char *, unsigned long));
char *xmem_gets(char * _WHERE(const char *, const char *, unsigned long));
#endif
int xmem_vsprintf(char *, const char *, va_list _WHERE(const char *, const char *, unsigned long));
int xmem_sprintf(char *, const char *, ...);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -