home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Science / Science.zip / imdisp79.zip / MSHELL.H < prev    next >
C/C++ Source or Header  |  1991-02-01  |  2KB  |  62 lines

  1. /*----------------------------------------------------------------------
  2.  *++
  3.  *  mshell.h -- Dynamic memory handler interface
  4.  *  Description: mshell.h provides the interface definitions for the dynamic
  5.  *  memory handler.
  6.  *  See mshell.c for complete documentation.
  7.  *+-
  8.  *  $Log$
  9.  *--
  10.  */
  11.  
  12. /* Include files which may be needed */
  13. #if !defined(printf)
  14. #include <stdio.h>
  15. #endif
  16.  
  17. #if !defined(malloc)
  18. #include <malloc.h>
  19. #endif
  20.  
  21. #if !defined(strcpy)
  22. #include <string.h>
  23. #endif
  24.  
  25. /* Compilation options */
  26. #define MEM_LIST        /* Build internal list */
  27. #define MEM_WHERE        /* Keep track of memory block source */
  28.  
  29. /* Interface functions */
  30. unsigned long    Mem_Used(void) ;
  31. void        Mem_Display(FILE *) ;
  32.  
  33. /* Interface functions to access only through macros */
  34. #if defined(MEM_WHERE)
  35. void        *mem_alloc(size_t, char *, int) ;
  36. void        *mem_realloc(void *, size_t, char *, int) ;
  37. void        mem_free(void *, char *, int) ;
  38. char        *mem_strdup(char *, char *, int) ;
  39. #else
  40. void        *mem_alloc(size_t) ;
  41. void        *mem_realloc(void *, size_t) ;
  42. void        mem_free(void *) ;
  43. char        *mem_strdup(char *) ;
  44. #endif
  45.  
  46. /* Interface macros */
  47. #if !defined(__MSHELL__)
  48. #if defined(MEM_WHERE)
  49. #define malloc(a)        mem_alloc((a),__FILE__,__LINE__)
  50. #define realloc(a,b)        mem_realloc((a),(b),__FILE__,__LINE__)
  51. #define free(a)            mem_free((a),__FILE__,__LINE__)
  52. #define strdup(a)        mem_strdup((a),__FILE__,__LINE__)
  53. #else
  54. #define malloc(a)        mem_alloc(a)
  55. #define realloc(a, b)        mem_realloc((a),(b))
  56. #define free(a)            mem_free(a)
  57. #define strdup(a)        mem_strdup(a)
  58. #endif
  59. #endif
  60.  
  61. /*----------------------------------------------------------------------*/
  62.