home *** CD-ROM | disk | FTP | other *** search
/ C/C++ User's Journal & Wi…eveloper's Journal Tools / C-C__Users_Journal_and_Windows_Developers_Journal_Tools_1997.iso / windbase / windbase.exe / MEMSLC.3 / MYMAL.C < prev    next >
C/C++ Source or Header  |  1995-12-10  |  3KB  |  92 lines

  1. /*****************************************************************************\
  2. **                                                                           **
  3. **  WW     WW IIIIIIII NNN   NN DDDDDDD  BBBBBBB     AA     SSSSSS EEEEEEEE  **
  4. **  WW  W  WW    II    NNNN  NN DD    DD BB    BB  AA  AA  SS      EE        **
  5. **  WW  W  WW    II    NN NN NN DD    DD BBBBBBB  AAAAAAAA  SSSSSS EEEEEE    **
  6. **   WW W WW     II    NN  NNNN DD    DD BB    BB AA    AA      SS EE        **
  7. **    WWWWW   IIIIIIII NN   NNN DDDDDDD  BBBBBBB  AA    AA SSSSSS  EEEEEEEE  **
  8. **                                                                           **
  9. **   SSSSSS  OOOOOO  FFFFFFFF TTTTTTTT WW     WW    AA    RRRRRRR  EEEEEEEE  **
  10. **  SS      OO    OO FF          TT    WW  W  WW  AA  AA  RR    RR EE        **
  11. **   SSSSS  OO    OO FFFFF       TT    WW  W  WW AAAAAAAA RRRRRRR  EEEEEE    **
  12. **       SS OO    OO FF          TT     WW W WW  AA    AA RR   RR  EE        **
  13. **  SSSSSS   OOOOOO  FF          TT      WWWWW   AA    AA RR    RR EEEEEEEE  **
  14. **                                                                           **
  15. *********** NOTICE ************************************************************
  16. **        This file contains valuable trade secrets and proprietary          **
  17. **        assets of Windbase Software Inc.  Embodying substantial            **
  18. **        creative efforts and confidential information.  Unauthorized       **
  19. **        use, copying, decompiling, translating, disclosure or              **
  20. **        transfer, of any kind, is strictly prohibited.                     **
  21. **                                                                           **
  22. **        COPYRIGHT (C) 1992, 1993, 1994.  Windbase Software Inc.            **
  23. **        ALL RIGHTS RESERVED.                                               **
  24. \*****************************************************************************/
  25.  
  26. #include <stdio.h>
  27. #include <malloc.h>
  28.  
  29. /*
  30. ** User defined memory
  31. **
  32. ** It is very important not to include the memsl.h header file
  33. ** or not to define WBMEMTRACE/WBUSERMEM (if the memsl header
  34. ** file is needed) as this would cause a recursive situation
  35. ** where the malloc() and free() calls below would be redifined
  36. ** by the macro definitions of malloc and free, which we want
  37. ** to be the real malloc() and free().
  38. **
  39. ** If the memsl.h header file is included be sure to use the
  40. ** following defines:
  41. ** #if defined(WBMEMTRACE) || defined(WBUSERMEM)
  42. ** #  undef WBMEMTRACE
  43. ** #  undef WBUSERMEM
  44. ** #endif
  45. */
  46.  
  47. #undef WBMEMTRACE
  48. #undef WBUSERMEM
  49. #include "../memsl.h"
  50.  
  51. int i;
  52.  
  53. #ifdef WBSTDC
  54.   void *MyMalloc(void *notused, unsigned int size)
  55. #else
  56.   void *MyMalloc(notused, size)
  57.     void *notused;
  58.     unsigned int size;
  59. #endif
  60.   {
  61.     void *ritem;
  62.  
  63.     WBTrcEntry(0,"MyMalloc",("%p, %d",notused,size));
  64.  
  65.     notused = notused;
  66.  
  67.     printf("MyMalloc(): %d\n",++i);
  68.  
  69.     ritem = malloc(size);
  70.  
  71.     WBTrcReturn(0,ritem,("%p",ritem));
  72.   }
  73.  
  74. #ifdef WBSTDC
  75.   void MyFree(void *notused, void *item)
  76. #else
  77.   void MyFree(notused, item)
  78.     void *notused;
  79.     void *item;
  80. #endif
  81.   {
  82.     WBTrcEntry(0,"MyFree",("%p, %p",notused,item));
  83.  
  84.     notused = notused;
  85.  
  86.     printf("MyFree(): %d\n",--i);
  87.  
  88.     free(item);
  89.  
  90.     WBTrcVReturn(WBTRC_MEMORY,(""));
  91.   }
  92.