home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ool_main.zip / ool / include / xmemchk.h < prev    next >
C/C++ Source or Header  |  1998-04-07  |  5KB  |  84 lines

  1. #ifndef __XMEMCHECK_H__
  2. #define __XMEMCHECK_H__
  3.  
  4. /*===========================================================================*/
  5. /* OOL ------------------- the Open Object Library ------------------- r 1.0 */
  6. /*===========================================================================*/
  7. /*                              class: XMemoryCheck                          */
  8. /*                       derived from: -                                     */
  9. /*                        last update: 9/97                                  */
  10. /*                      programmed by: Stefan von Brauk                      */
  11. /*===========================================================================*/
  12.  
  13.  
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include "xobject.h"
  17.  
  18. #if __cplusplus
  19. extern "C" {
  20. #endif
  21.  
  22. #if !defined( __WATCOMC__ )
  23.    void dump_memcheck();
  24.    void * memcheck_calloc( size_t, size_t, const char *, const int);
  25.    void * memcheck_malloc( size_t, const char *, const int);
  26.    void * memcheck_realloc( void*, size_t, const char *, const int);
  27.    void memcheck_free( void*, const char *, const int);
  28.    void * memcheck_memcmp( void * buf1, void * buf2, size_t count, const char * file, const int line);
  29.    void * memcheck_memcpy( void * dest, void * src, size_t count, const char * file, const int line);
  30.    void * memcheck_memmove( void * dest, void * src, size_t count, const char * file, const int line);
  31.    void * memcheck_memset( void * dest, int c, size_t count, const char * file, const int line);
  32.    char * memcheck_strcat( char * string1, const char * string2, const char * file, const int line);
  33.    char * memcheck_strcpy( char * string1, const char * string2, const char * file, const int line);
  34.    char * memcheck_strncpy( char * string1, const char * string2, size_t count, const char * file, const int line);
  35.    int memcheck_strncmp( char * string1, const char * string2, size_t count, const char * file, const int line);
  36. #else
  37.    void __export dump_memcheck();
  38.    void __export * memcheck_calloc( size_t, size_t, const char *, const int);
  39.    void __export * memcheck_malloc( size_t, const char *, const int);
  40.    void __export * memcheck_realloc( void*, size_t, const char *, const int);
  41.    void __export memcheck_free( void*, const char *, const int);
  42.    void __export * memcheck_memcmp( void * buf1, void * buf2, size_t count, const char * file, const int line);
  43.    void __export * memcheck_memcpy( void * dest, void * src, size_t count, const char * file, const int line);
  44.    void __export * memcheck_memmove( void * dest, void * src, size_t count, const char * file, const int line);
  45.    void __export * memcheck_memset( void * dest, int c, size_t count, const char * file, const int line);
  46.    char __export * memcheck_strcat( char * string1, const char * string2, const char * file, const int line);
  47.    char __export * memcheck_strcpy( char * string1, const char * string2, const char * file, const int line);
  48.    char __export * memcheck_strncpy( char * string1, const char * string2, size_t count, const char * file, const int line);
  49.    int __export memcheck_strncmp( char * string1, const char * string2, size_t count, const char * file, const int line);
  50. #endif
  51.  
  52. #if __cplusplus
  53. };
  54. #endif
  55.  
  56.  
  57. #ifndef __CREATE_DLL__
  58. #ifdef DEBUG
  59.    #define calloc(num, length)                     memcheck_calloc( (int) num, (int) length, __FILE__, __LINE__)
  60.    #define malloc(length)                          memcheck_malloc( length, __FILE__, __LINE__)
  61.    #define realloc(pointer,length)                 memcheck_realloc( pointer, length, __FILE__, __LINE__)
  62.    #define free(pointer)                           memcheck_free( pointer, __FILE__, __LINE__ )
  63.    #define memcmp(dest, src, count)                memcheck_memcmp( dest, src, count, __FILE__, __LINE__ )
  64.    #define memcpy(dest, src, count)                memcheck_memcpy( dest, (void*) src, (int) count, __FILE__, __LINE__ )
  65.    #define memmove(dest, src, count)               memcheck_memmove( dest, src, count, __FILE__, __LINE__ )
  66.    #define memset(dest, c, count)                  memcheck_memset( dest, c, count, __FILE__, __LINE__ )
  67.    #define strcat(string1, string2)                memcheck_strcat( string1, string2, __FILE__, __LINE__ )
  68.    #define strcpy(string1, string2)                memcheck_strcpy( string1, string2, __FILE__, __LINE__ )
  69.    #define strncpy(string1, string2, count)        memcheck_strncpy( string1, string2, count, __FILE__, __LINE__ )
  70.    #define strncmp(string1, string2, count)        memcheck_strncmp( string1, string2, count, __FILE__, __LINE__ )
  71. #endif
  72.  
  73. #if __cplusplus
  74.  
  75. class XMemoryCheck
  76. {
  77.    public:
  78.       XMemoryCheck() {;}
  79.       ~XMemoryCheck() { dump_memcheck(); }
  80. };
  81. #endif
  82. #endif
  83. #endif
  84.