home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Sources / FWRepMem.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  3.3 KB  |  154 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWRepMem.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWOS.hpp"
  11.  
  12. #if defined(FW_PROFILER_CALLS) && defined(__MWERKS__)
  13. #pragma profile on
  14. #endif
  15.  
  16. #ifndef FWINK_H
  17. #include "FWInk.h"
  18. #endif
  19.  
  20. #ifndef FWSTYLE_H
  21. #include "FWStyle.h"
  22. #endif
  23.  
  24. #ifndef FWFONT_H
  25. #include "FWFont.h"
  26. #endif
  27.  
  28. #ifndef FWPAT_H
  29. #include "FWPat.h"
  30. #endif
  31.  
  32. #ifndef FWBWPAT_H
  33. #include "FWBWPat.h"
  34. #endif
  35.  
  36. #ifndef FWCPAT_H
  37. #include "FWCPat.h"
  38. #endif
  39.  
  40. // ----- Foundation Includes -----
  41.  
  42. #ifndef FWFIXMEM_H
  43. #include "FWFixMem.h"
  44. #endif
  45.  
  46. //========================================================================================
  47. // Memory management
  48. //========================================================================================
  49.  
  50. #define FW_SUBALLOCATE
  51.  
  52. //----------------------------------------------------------------------------------------
  53. // FW_CInkRep
  54. //----------------------------------------------------------------------------------------
  55.  
  56. static FW_CFixedAllocator gInkAllocator = sizeof(FW_CInkRep);
  57.  
  58. void* FW_CInkRep::operator new(size_t size)
  59. {
  60.     FW_ASSERT(size == sizeof(FW_CInkRep));
  61. #ifdef FW_SUBALLOCATE
  62.     return gInkAllocator.Allocate();
  63. #else
  64.     return ::operator new(size);
  65. #endif
  66. }
  67.  
  68. void FW_CInkRep::operator delete(void* p)
  69. {
  70. #ifdef FW_SUBALLOCATE
  71.     gInkAllocator.Free(p);
  72. #else
  73.     ::operator delete(p);
  74. #endif
  75. }
  76.  
  77. //----------------------------------------------------------------------------------------
  78. // FW_CStyleRep
  79. //----------------------------------------------------------------------------------------
  80.  
  81. static FW_CFixedAllocator gStyleAllocator = sizeof(FW_CStyleRep);
  82.  
  83. void* FW_CStyleRep::operator new(size_t size)
  84. {
  85.     FW_ASSERT(size == sizeof(FW_CStyleRep));
  86. #ifdef FW_SUBALLOCATE
  87.     return gStyleAllocator.Allocate();
  88. #else
  89.     return ::operator new(size);
  90. #endif
  91. }
  92.  
  93. void FW_CStyleRep::operator delete(void* p)
  94. {
  95. #ifdef FW_SUBALLOCATE
  96.     gStyleAllocator.Free(p);
  97. #else
  98.     ::operator delete(p);
  99. #endif
  100. }
  101.  
  102. //----------------------------------------------------------------------------------------
  103. // FW_CFontRep
  104. //----------------------------------------------------------------------------------------
  105.  
  106. static FW_CFixedAllocator gFontAllocator = sizeof(FW_CFontRep);
  107.  
  108. void* FW_CFontRep::operator new(size_t size)
  109. {
  110.     FW_ASSERT(size == sizeof(FW_CFontRep));
  111. #ifdef FW_SUBALLOCATE
  112.     return gFontAllocator.Allocate();
  113. #else
  114.     return ::operator new(size);
  115. #endif
  116. }
  117.  
  118. void FW_CFontRep::operator delete(void* p)
  119. {
  120. #ifdef FW_SUBALLOCATE
  121.     gFontAllocator.Free(p);
  122. #else
  123.     ::operator delete(p);
  124. #endif
  125. }
  126.  
  127. //----------------------------------------------------------------------------------------
  128. // FW_CPatternRep
  129. //----------------------------------------------------------------------------------------
  130.  
  131. #define MAX(a, b)    ((a) > (b) ? (a) : (b))
  132.  
  133. static FW_CFixedAllocator gPatternAllocator =
  134.     MAX(sizeof(FW_CBWPatternRep), sizeof(FW_CColorPatternRep));
  135.  
  136. void* FW_CPatternRep::operator new(size_t size)
  137. {
  138. #ifdef FW_SUBALLOCATE
  139.     return gPatternAllocator.Allocate();
  140. #else
  141.     return ::operator new(size);
  142. #endif
  143. }
  144.  
  145. void FW_CPatternRep::operator delete(void* p)
  146. {
  147. #ifdef FW_SUBALLOCATE
  148.     gPatternAllocator.Free(p);
  149. #else
  150.     ::operator delete(p);
  151. #endif
  152. }
  153.  
  154.