home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 3.5 KB | 168 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: PRRepMem.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef PRSHATTR_H
- #include "PRShAttr.h"
- #endif
-
- #ifndef FWFIXMEM_H
- #include "FWFixMem.h"
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment FW_Graphics
- #endif
-
- #ifdef FW_NATIVE_EXCEPTIONS
-
- //========================================================================================
- // Memory management
- //========================================================================================
-
- #define FW_SUBALLOCATE
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivInkRep
- //----------------------------------------------------------------------------------------
-
- static FW_CFixedAllocator gInkAllocator(
- sizeof(FW_CPrivInkRep)
- #ifdef FW_DEBUG
- , "FW_CPrivInkRep"
- #endif
- );
-
- void* FW_CPrivInkRep::operator new(size_t size)
- {
- #ifndef FW_DEBUG
- FW_UNUSED(size);
- #endif
- FW_ASSERT(size == sizeof(FW_CPrivInkRep));
- #ifdef FW_SUBALLOCATE
- return gInkAllocator.Allocate();
- #else
- return ::operator new(size);
- #endif
- }
-
- void FW_CPrivInkRep::operator delete(void* p)
- {
- #ifdef FW_SUBALLOCATE
- gInkAllocator.Free(p);
- #else
- ::operator delete(p);
- #endif
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivStyleRep
- //----------------------------------------------------------------------------------------
-
- static FW_CFixedAllocator gStyleAllocator (
- sizeof(FW_CPrivStyleRep)
- #ifdef FW_DEBUG
- , "FW_CPrivStyleRep"
- #endif
- );
-
- void* FW_CPrivStyleRep::operator new(size_t size)
- {
- #ifndef FW_DEBUG
- FW_UNUSED(size);
- #endif
- FW_ASSERT(size == sizeof(FW_CPrivStyleRep));
- #ifdef FW_SUBALLOCATE
- return gStyleAllocator.Allocate();
- #else
- return ::operator new(size);
- #endif
- }
-
- void FW_CPrivStyleRep::operator delete(void* p)
- {
- #ifdef FW_SUBALLOCATE
- gStyleAllocator.Free(p);
- #else
- ::operator delete(p);
- #endif
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivFontRep
- //----------------------------------------------------------------------------------------
-
- static FW_CFixedAllocator gFontAllocator (
- sizeof(FW_CPrivFontRep)
- #ifdef FW_DEBUG
- , "FW_CPrivFontRep"
- #endif
- );
-
- void* FW_CPrivFontRep::operator new(size_t size)
- {
- #ifndef FW_DEBUG
- FW_UNUSED(size);
- #endif
- FW_ASSERT(size == sizeof(FW_CPrivFontRep));
- #ifdef FW_SUBALLOCATE
- return gFontAllocator.Allocate();
- #else
- return ::operator new(size);
- #endif
- }
-
- void FW_CPrivFontRep::operator delete(void* p)
- {
- #ifdef FW_SUBALLOCATE
- gFontAllocator.Free(p);
- #else
- ::operator delete(p);
- #endif
- }
-
-
- //----------------------------------------------------------------------------------------
- // FW_CPrivPatternRep
- //----------------------------------------------------------------------------------------
-
- #define MAX(a, b) \
- ((a) > (b) ? (a) : (b))
-
- static FW_CFixedAllocator gPatternAllocator (
- MAX(sizeof(FW_CPrivBWPatternRep), sizeof(FW_CPrivColorPatternRep))
- #ifdef FW_DEBUG
- , "FW_CPriv{BW|Color}PatternRep"
- #endif
- );
-
- void* FW_CPrivPatternRep::operator new(size_t size)
- {
- #ifdef FW_SUBALLOCATE
- FW_UNUSED(size);
- return gPatternAllocator.Allocate();
- #else
- return ::operator new(size);
- #endif
- }
-
- void FW_CPrivPatternRep::operator delete(void* p)
- {
- #ifdef FW_SUBALLOCATE
- gPatternAllocator.Free(p);
- #else
- ::operator delete(p);
- #endif
- }
-
- #endif
-