Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

873 lines
22 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1994.
  5. //
  6. // File: heap.hxx
  7. //
  8. // Contents: Heap code headers
  9. //
  10. // Classes: CHeap
  11. //
  12. // History: 29-Mar-94 PhilipLa Created
  13. // 05-Feb-95 KentCe Use Win95 Shared Heap.
  14. // 10-Apr095 HenryLee Added global LUID
  15. // 10-May-95 KentCe Defer Heap Destruction to the last
  16. // process detach.
  17. //
  18. //----------------------------------------------------------------------------
  19. #ifndef __HEAP_HXX__
  20. #define __HEAP_HXX__
  21. #include <smblock.hxx>
  22. #include <memdebug.hxx>
  23. #include <msf.hxx>
  24. #include <df32.hxx>
  25. //Space to reserve for heap.
  26. const ULONG MINHEAPGROWTH = 4096;
  27. const ULONG INITIALHEAPSIZE = 16384;
  28. #ifdef MULTIHEAP
  29. #include <ntpsapi.h>
  30. class CPerContext;
  31. #endif
  32. //+-------------------------------------------------------------------------
  33. //
  34. // Class: CLockDfMutex
  35. //
  36. // Purpose: Simple class to guarantee that a DfMutex is unlocked
  37. //
  38. // History: 29-Apr-95 DonnaLi Created
  39. //
  40. //--------------------------------------------------------------------------
  41. class CLockDfMutex
  42. {
  43. public:
  44. CLockDfMutex(CDfMutex& dmtx);
  45. ~CLockDfMutex(void);
  46. private:
  47. CDfMutex& _dmtx;
  48. };
  49. //+-------------------------------------------------------------------------
  50. //
  51. // Member: CLockDfMutex::CLockDfMutex
  52. //
  53. // Synopsis: Get mutex
  54. //
  55. // Arguments: [dmtx] -- mutex to get
  56. //
  57. // History: 29-Apr-95 DonnaLi Created
  58. //
  59. //--------------------------------------------------------------------------
  60. inline CLockDfMutex::CLockDfMutex(CDfMutex& dmtx) : _dmtx(dmtx)
  61. {
  62. _dmtx.Take(DFM_TIMEOUT);
  63. }
  64. //+-------------------------------------------------------------------------
  65. //
  66. // Member: CLockDfMutex::~CLockDfMutex
  67. //
  68. // Synopsis: Release the mutex
  69. //
  70. // History: 29-Apr-95 DonnaLi Created
  71. //
  72. //--------------------------------------------------------------------------
  73. inline CLockDfMutex::~CLockDfMutex(void)
  74. {
  75. _dmtx.Release();
  76. }
  77. //
  78. // Take advantage of Windows 95 Shared Heap.
  79. //
  80. #if !defined(_CHICAGO_)
  81. //+---------------------------------------------------------------------------
  82. //
  83. // Class: CBlockPreHeader
  84. //
  85. // Purpose: Required header fields for a block
  86. //
  87. // History: 29-Mar-94 PhilipLa Created
  88. //
  89. //----------------------------------------------------------------------------
  90. class CBlockPreHeader
  91. {
  92. protected:
  93. SIZE_T _ulSize; //Size of block
  94. BOOL _fFree; //TRUE if block is free
  95. };
  96. //+---------------------------------------------------------------------------
  97. //
  98. // Class: CBlockHeader
  99. //
  100. // Purpose: Fields required for free blocks but overwritten for
  101. // allocated blocks.
  102. //
  103. // History: 29-Mar-94 PhilipLa Created
  104. //
  105. //----------------------------------------------------------------------------
  106. class CBlockHeader: public CBlockPreHeader
  107. {
  108. public:
  109. inline SIZE_T GetSize(void) const;
  110. inline BOOL IsFree(void) const;
  111. inline SIZE_T GetNext(void) const;
  112. inline void SetSize(SIZE_T ulSize);
  113. inline void SetFree(void);
  114. inline void ResetFree(void);
  115. inline void SetNext(SIZE_T ulNext);
  116. private:
  117. SIZE_T _ulNext; //Pointer to next block
  118. };
  119. //+---------------------------------------------------------------------------
  120. //
  121. // Member: CBlockHeader::GetSize, public
  122. //
  123. // Synopsis: Returns the size of the block
  124. //
  125. // History: 30-Mar-94 PhilipLa Created
  126. //
  127. //----------------------------------------------------------------------------
  128. inline SIZE_T CBlockHeader::GetSize(void) const
  129. {
  130. return _ulSize;
  131. }
  132. //+---------------------------------------------------------------------------
  133. //
  134. // Member: CBlockHeader::IsFree, public
  135. //
  136. // Synopsis: Returns free state of block
  137. //
  138. // History: 30-Mar-94 PhilipLa Created
  139. //
  140. //----------------------------------------------------------------------------
  141. inline BOOL CBlockHeader::IsFree(void) const
  142. {
  143. memAssert (_fFree == TRUE || _fFree == FALSE); // check for corruption
  144. return _fFree;
  145. }
  146. //+---------------------------------------------------------------------------
  147. //
  148. // Member: CBlockHeader::GetNext, public
  149. //
  150. // Synopsis: Return next offset
  151. //
  152. // History: 30-Mar-94 PhilipLa Created
  153. //
  154. //----------------------------------------------------------------------------
  155. inline SIZE_T CBlockHeader::GetNext(void) const
  156. {
  157. return _ulNext;
  158. }
  159. //+---------------------------------------------------------------------------
  160. //
  161. // Member: CBlockHeader::SetSize, public
  162. //
  163. // Synopsis: Set size of block
  164. //
  165. // History: 30-Mar-94 PhilipLa Created
  166. //
  167. //----------------------------------------------------------------------------
  168. inline void CBlockHeader::SetSize(SIZE_T ulSize)
  169. {
  170. _ulSize = ulSize;
  171. }
  172. //+---------------------------------------------------------------------------
  173. //
  174. // Member: CBlockHeader::SetFree, public
  175. //
  176. // Synopsis: Set this block to free
  177. //
  178. // History: 30-Mar-94 PhilipLa Created
  179. //
  180. //----------------------------------------------------------------------------
  181. inline void CBlockHeader::SetFree(void)
  182. {
  183. _fFree = TRUE;
  184. }
  185. //+---------------------------------------------------------------------------
  186. //
  187. // Member: CBlockHeader::ResetFree, public
  188. //
  189. // Synopsis: Set this block to !free
  190. //
  191. // History: 30-Mar-94 PhilipLa Created
  192. //
  193. //----------------------------------------------------------------------------
  194. inline void CBlockHeader::ResetFree(void)
  195. {
  196. _fFree = FALSE;
  197. }
  198. //+---------------------------------------------------------------------------
  199. //
  200. // Member: CBlockHeader::SetNext, public
  201. //
  202. // Synopsis: Set next offset
  203. //
  204. // History: 30-Mar-94 PhilipLa Created
  205. //
  206. //----------------------------------------------------------------------------
  207. inline void CBlockHeader::SetNext(SIZE_T ulNext)
  208. {
  209. _ulNext = ulNext;
  210. }
  211. const ULONG CBLOCKMIN = ((sizeof(CBlockHeader) & 7)
  212. ? sizeof(CBlockHeader) +
  213. (8 - (sizeof(CBlockHeader) & 7))
  214. : sizeof(CBlockHeader));
  215. //+---------------------------------------------------------------------------
  216. //
  217. // Class: CHeapHeader
  218. //
  219. // Purpose: Header information for shared memory heap
  220. //
  221. // Interface:
  222. //
  223. // History: 30-Mar-94 PhilipLa Created
  224. //
  225. // Notes: The size of this structure must be a multiple of 8 bytes.
  226. //
  227. //----------------------------------------------------------------------------
  228. class CHeapHeader
  229. {
  230. public:
  231. inline SIZE_T GetFirstFree(void) const;
  232. inline void SetFirstFree(SIZE_T ulNew);
  233. inline BOOL IsCompacted(void) const;
  234. inline void SetCompacted(void);
  235. inline void ResetCompacted(void);
  236. inline void ResetAllocedBlocks(void);
  237. inline SIZE_T IncrementAllocedBlocks(void);
  238. inline SIZE_T DecrementAllocedBlocks(void);
  239. inline SIZE_T GetAllocedBlocks(void);
  240. inline DFLUID IncrementLuid(void);
  241. inline void ResetLuid(void);
  242. #if DBG == 1
  243. SIZE_T _ulAllocedBytes;
  244. SIZE_T _ulFreeBytes;
  245. SIZE_T _ulFreeBlocks;
  246. #endif
  247. private:
  248. SIZE_T _ulFirstFree;
  249. SIZE_T _ulAllocedBlocks;
  250. BOOL _fIsCompacted;
  251. DFLUID _dfLuid;
  252. #if DBG == 1
  253. SIZE_T ulPad;
  254. #endif
  255. };
  256. //+---------------------------------------------------------------------------
  257. //
  258. // Member: CHeapHeader::GetFirstFree, public
  259. //
  260. // Synopsis: Return first free information
  261. //
  262. // History: 30-Mar-94 PhilipLa Created
  263. //
  264. //----------------------------------------------------------------------------
  265. inline SIZE_T CHeapHeader::GetFirstFree(void) const
  266. {
  267. return _ulFirstFree;
  268. }
  269. //+---------------------------------------------------------------------------
  270. //
  271. // Member: CHeapHeader::SetFirstFree, public
  272. //
  273. // Synopsis: Set first free information
  274. //
  275. // History: 30-Mar-94 PhilipLa Created
  276. //
  277. //----------------------------------------------------------------------------
  278. inline void CHeapHeader::SetFirstFree(SIZE_T ulNew)
  279. {
  280. _ulFirstFree = ulNew;
  281. }
  282. //+---------------------------------------------------------------------------
  283. //
  284. // Member: CHeapHeader::IsCompacted, public
  285. //
  286. // Synopsis: Return TRUE if heap is compacted
  287. //
  288. // History: 30-Mar-94 PhilipLa Created
  289. //
  290. //----------------------------------------------------------------------------
  291. inline BOOL CHeapHeader::IsCompacted(void) const
  292. {
  293. return _fIsCompacted;
  294. }
  295. //+---------------------------------------------------------------------------
  296. //
  297. // Member: CHeapHeader::SetCompacted, public
  298. //
  299. // Synopsis: Set compacted bit
  300. //
  301. // History: 30-Mar-94 PhilipLa Created
  302. //
  303. //----------------------------------------------------------------------------
  304. inline void CHeapHeader::SetCompacted(void)
  305. {
  306. _fIsCompacted = TRUE;
  307. }
  308. //+---------------------------------------------------------------------------
  309. //
  310. // Member: CHeapHeader::ResetCompacted, public
  311. //
  312. // Synopsis: Reset compacted bit
  313. //
  314. // History: 30-Mar-94 PhilipLa Created
  315. //
  316. //----------------------------------------------------------------------------
  317. inline void CHeapHeader::ResetCompacted(void)
  318. {
  319. _fIsCompacted = FALSE;
  320. }
  321. //+---------------------------------------------------------------------------
  322. //
  323. // Member: CHeapHeader::IncrementLuid, public
  324. //
  325. // Synopsis: Increment the global LUID
  326. //
  327. // History: 06-Apr-95 HenryLee Created
  328. //
  329. //----------------------------------------------------------------------------
  330. inline ULONG CHeapHeader::IncrementLuid()
  331. {
  332. return ++_dfLuid;
  333. }
  334. //+---------------------------------------------------------------------------
  335. //
  336. // Member: CHeapHeader::ResetLuid, public
  337. //
  338. // Synopsis: Increment the global LUID
  339. //
  340. // History: 06-Apr-95 HenryLee Created
  341. //
  342. //----------------------------------------------------------------------------
  343. inline void CHeapHeader::ResetLuid()
  344. {
  345. _dfLuid = LUID_BASE; // some LUIDs are reserved
  346. }
  347. #ifdef MULTIHEAP
  348. extern DFLUID gs_dfluid; // task memory support
  349. extern INT gs_iSharedHeaps; // number ofshared heaps
  350. #endif
  351. #else // define(_CHICAGO_)
  352. extern HANDLE gs_hSharedHeap; // hSharedHeap Handle for Win95.
  353. extern DFLUID gs_dfluid; // shared docfile LUID
  354. #endif // !define(_CHICAGO_)
  355. //+---------------------------------------------------------------------------
  356. //
  357. // Class: CSmAllocator
  358. //
  359. // Purpose: Shared memory heap implementation
  360. //
  361. // History: 29-Mar-94 PhilipLa Created
  362. // 05-Feb-95 KentCe Use Win95 Shared Heap.
  363. //
  364. //----------------------------------------------------------------------------
  365. class CSmAllocator: public IMalloc
  366. {
  367. public:
  368. inline CSmAllocator();
  369. inline ~CSmAllocator();
  370. STDMETHOD_(ULONG,AddRef) ( void );
  371. STDMETHOD_(ULONG,Release) ( void );
  372. STDMETHOD(QueryInterface) ( REFIID riid, void ** ppv );
  373. STDMETHOD_(void*,Alloc) ( SIZE_T cb );
  374. STDMETHOD_(void *,Realloc) ( void *pvCurrent, SIZE_T cbNeeded );
  375. STDMETHOD_(void,Free) ( void *pvMemToFree );
  376. STDMETHOD_(SIZE_T,GetSize) ( void * pv );
  377. STDMETHOD_(void,HeapMinimize) ( void );
  378. STDMETHOD_(int,DidAlloc) ( void * pv );
  379. inline SCODE Sync(void);
  380. inline DFLUID IncrementLuid(void);
  381. #if !defined(MULTIHEAP)
  382. SCODE Init ( LPWSTR pszName );
  383. #else
  384. SCODE Init ( ULONG ulHeapName, BOOL fUnmarshal );
  385. #endif
  386. inline void * GetBase(void);
  387. // This function is equivalent to Free above, except that is does
  388. // not attempt to first acquire the mutex. It should be used ONLY
  389. // when the calling function guarantees to already have the mutex.
  390. void FreeNoMutex (void * pv);
  391. #if !defined(MULTIHEAP)
  392. inline CDfMutex * GetMutex (void);
  393. #endif
  394. #ifdef MULTIHEAP
  395. void SetState (CSharedMemoryBlock *psmb, BYTE * pbBase,
  396. ULONG ulHeapName, CPerContext ** ppcPrev,
  397. CPerContext *ppcOwner);
  398. void GetState (CSharedMemoryBlock **ppsmb, BYTE ** ppbBase,
  399. ULONG *pulHeapName);
  400. inline const ULONG GetHeapName ();
  401. SCODE Uninit ();
  402. inline const ULONG GetHeapSize () { return _cbSize; };
  403. #if DBG == 1
  404. void PrintAllocatedBlocks(void);
  405. #endif
  406. #endif
  407. private:
  408. inline void DoFree (void *pv);
  409. #if !defined(MULTIHEAP)
  410. CDfMutex _dmtx;
  411. #endif
  412. //
  413. // Take advantage of Windows 95 Shared Heap.
  414. //
  415. #if !defined(_CHICAGO_)
  416. CBlockHeader * FindBlock(SIZE_T cb, CBlockHeader **ppbhPrev);
  417. inline CHeapHeader *GetHeader(void);
  418. inline CBlockHeader * GetAddress(SIZE_T ulOffset) const;
  419. inline ULONG GetOffset(CBlockHeader *pbh) const;
  420. inline SCODE Reset(void);
  421. #if DBG == 1
  422. void PrintFreeBlocks(void);
  423. #endif
  424. #ifdef MULTIHEAP
  425. CSharedMemoryBlock *_psmb;
  426. BYTE *_pbBase;
  427. ULONG _cbSize;
  428. CPerContext * _ppcOwner;
  429. ULONG _ulHeapName;
  430. ULONG _cRefs; // yes, this object has a lifetime now
  431. #else
  432. CSharedMemoryBlock _smb;
  433. BYTE *_pbBase;
  434. SIZE_T _cbSize;
  435. #endif // MULTIHEAP
  436. #else // defined(_CHICAGO_)
  437. HANDLE m_hSharedHeap;
  438. #endif // !defined(_CHICAGO_)
  439. };
  440. #ifdef MULTIHEAP
  441. extern CSmAllocator g_SmAllocator; // single-threaded allocator
  442. extern CSharedMemoryBlock g_smb; //performance optimization
  443. extern ULONG g_ulHeapName;
  444. extern CSmAllocator& GetTlsSmAllocator(); // all other threads
  445. extern TEB * g_pteb;
  446. #define g_smAllocator (GetTlsSmAllocator())
  447. //+---------------------------------------------------------------------------
  448. //
  449. // Class: CErrorSmAllocator
  450. //
  451. // Synopsis: returned by GetTlsSmAllocator for out of memory failures
  452. //
  453. // History: 02-May-1996 HenryLee Created
  454. //
  455. //----------------------------------------------------------------------------
  456. class CErrorSmAllocator : public CSmAllocator
  457. {
  458. public:
  459. STDMETHOD_(void*,Alloc) (SIZE_T cb) { return NULL; };
  460. STDMETHOD_(void*,Realloc) (void* pv, SIZE_T cb) { return NULL; };
  461. STDMETHOD_(void,Free) (void *pv) { return; };
  462. STDMETHOD_(SIZE_T,GetSize) (void *pv) { return 0; };
  463. STDMETHOD_(void,HeapMinimize) () { return; };
  464. STDMETHOD_(int,DidAlloc) (void *pv) { return FALSE; };
  465. SCODE Init (ULONG ul, BOOL f) { return STG_E_INSUFFICIENTMEMORY; };
  466. SCODE Sync (void) { return STG_E_INSUFFICIENTMEMORY; };
  467. };
  468. extern CErrorSmAllocator g_ErrorSmAllocator;
  469. extern IMalloc * g_pTaskAllocator;
  470. #else
  471. extern CSmAllocator g_smAllocator;
  472. #endif
  473. extern CRITICAL_SECTION g_csScratchBuffer;
  474. //+---------------------------------------------------------------------------
  475. //
  476. // Member: CSmAllocator::CSmAllocator, public
  477. //
  478. // Synopsis: Constructor
  479. //
  480. // History: 29-Mar-94 PhilipLa Created
  481. // 05-Feb-95 KentCe Use Win95 Shared Heap.
  482. //
  483. //----------------------------------------------------------------------------
  484. inline CSmAllocator::CSmAllocator(void)
  485. #if !defined(_CHICAGO_)
  486. #ifdef MULTIHEAP
  487. : _cbSize(0), _pbBase(NULL), _cRefs(1), _ulHeapName(0),
  488. _psmb(NULL), _ppcOwner(NULL)
  489. #else
  490. : _cbSize(0)
  491. #endif // MULTIHEAP
  492. #else
  493. : m_hSharedHeap(NULL)
  494. #endif
  495. {
  496. #if !defined(MULTIHEAP)
  497. InitializeCriticalSection(&g_csScratchBuffer);
  498. #ifdef COORD
  499. InitializeCriticalSection(&g_csResourceList);
  500. #endif
  501. #endif // MULTIHEAP
  502. }
  503. //+---------------------------------------------------------------------------
  504. //
  505. // Member: CSmAllocator::~CSmAllocator, public
  506. //
  507. // Synopsis: Destructor
  508. //
  509. // History: 29-Mar-94 PhilipLa Created
  510. // 05-Feb-95 KentCe Use Win95 Shared Heap.
  511. // 10-May-95 KentCe Defer Heap Destruction to the last
  512. // process detach.
  513. //
  514. //----------------------------------------------------------------------------
  515. inline CSmAllocator::~CSmAllocator(void)
  516. {
  517. #if !defined(MULTIHEAP)
  518. DeleteCriticalSection(&g_csScratchBuffer);
  519. #ifdef COORD
  520. DeleteCriticalSection(&g_csResourceList);
  521. #endif
  522. #endif // MULTIHEAP
  523. }
  524. //+---------------------------------------------------------------------------
  525. //
  526. // Member: CSmAllocator::Sync, public
  527. //
  528. // Synopsis: Sync memory to global state.
  529. //
  530. // Arguments: None.
  531. //
  532. // Returns: Appropriate status code
  533. //
  534. // History: 29-Mar-94 PhilipLa Created
  535. // 05-Feb-95 KentCe Use Win95 Shared Heap.
  536. //
  537. //----------------------------------------------------------------------------
  538. inline SCODE CSmAllocator::Sync(void)
  539. {
  540. SCODE sc = S_OK;
  541. #if !defined(_CHICAGO_)
  542. #if !defined(MULTIHEAP)
  543. if (!_smb.IsSynced())
  544. {
  545. CLockDfMutex lckdmtx(_dmtx);
  546. sc = _smb.Sync();
  547. _cbSize = _smb.GetSize();
  548. }
  549. #else
  550. if (_psmb)
  551. {
  552. if (!_psmb->IsSynced())
  553. {
  554. sc = _psmb->Sync();
  555. }
  556. _cbSize = _psmb->GetSize();
  557. }
  558. #endif
  559. #endif
  560. return sc;
  561. }
  562. //+---------------------------------------------------------------------------
  563. //
  564. // Member: CSmAllocator::IncrementLuid, public
  565. //
  566. // Synopsis: Increments the global LUID
  567. //
  568. // Arguments: None.
  569. //
  570. // Returns: Appropriate status code
  571. //
  572. // History: 06-Apr-95 HenryLee Created
  573. //----------------------------------------------------------------------------
  574. inline DFLUID CSmAllocator::IncrementLuid(void)
  575. {
  576. #if !defined(MULTIHEAP)
  577. CLockDfMutex lckdmx(_dmtx);
  578. #endif
  579. #ifdef _CHICAGO_
  580. //
  581. // On Chicago, we merely increment the globally available
  582. // LUID to the next value.
  583. //
  584. return ++gs_dfluid;
  585. #else
  586. return _pbBase ? GetHeader()->IncrementLuid() :
  587. InterlockedIncrement((LONG*)&gs_dfluid);
  588. #endif
  589. }
  590. //+---------------------------------------------------------------------------
  591. //
  592. // Member: CSmAllocator::GetBase, public
  593. //
  594. // Synopsis: Return pointer to base of heap
  595. //
  596. // History: 29-Mar-94 PhilipLa Created
  597. // 05-Feb-95 KentCe Use Win95 Shared Heap.
  598. //
  599. //----------------------------------------------------------------------------
  600. inline void * CSmAllocator::GetBase(void)
  601. {
  602. #if defined(_CHICAGO_)
  603. return NULL;
  604. #else
  605. return _pbBase;
  606. #endif
  607. }
  608. #if !defined(MULTIHEAP)
  609. //+---------------------------------------------------------------------------
  610. //
  611. // Member: CSmAllocator::GetMutex, public
  612. //
  613. // Synopsis: Return a pointer to the Mutex
  614. //
  615. // History: 19-Jul-95 SusiA Created
  616. //
  617. //----------------------------------------------------------------------------
  618. inline CDfMutex * CSmAllocator::GetMutex(void)
  619. {
  620. return &_dmtx;
  621. }
  622. #endif
  623. //
  624. // Take advantage of Windows 95 Shared Heap.
  625. //
  626. #if !defined(_CHICAGO_)
  627. //+---------------------------------------------------------------------------
  628. //
  629. // Member: CSmAllocator::GetAddress, private
  630. //
  631. // Synopsis: Returns an address given an offset from the base
  632. //
  633. // Arguments: [ulOffset] -- Offset to convert to address
  634. //
  635. // History: 29-Mar-94 PhilipLa Created
  636. //
  637. //----------------------------------------------------------------------------
  638. inline CBlockHeader * CSmAllocator::GetAddress(SIZE_T ulOffset) const
  639. {
  640. return (ulOffset == 0) ? NULL : (CBlockHeader *)(_pbBase + ulOffset);
  641. }
  642. //+---------------------------------------------------------------------------
  643. //
  644. // Member: CSmAllocator::GetOffset
  645. //
  646. // Synopsis: Returns a byte offset from the base given a pointer
  647. //
  648. // Arguments: [pbh] -- Pointer to convert to offset
  649. //
  650. // History: 29-Mar-94 PhilipLa Created
  651. //
  652. //----------------------------------------------------------------------------
  653. inline ULONG CSmAllocator::GetOffset(CBlockHeader *pbh) const
  654. {
  655. memAssert((BYTE *)pbh >= _pbBase && (BYTE*)pbh < _pbBase + _cbSize);
  656. return (ULONG)((ULONG_PTR)pbh - (ULONG_PTR)_pbBase);
  657. }
  658. //+---------------------------------------------------------------------------
  659. //
  660. // Member: CSmAllocator::GetHeader, private
  661. //
  662. // Synopsis: Return pointer to CHeapHeader for this heap
  663. //
  664. // History: 30-Mar-94 PhilipLa Created
  665. //
  666. //----------------------------------------------------------------------------
  667. inline CHeapHeader * CSmAllocator::GetHeader(void)
  668. {
  669. return (CHeapHeader *)_pbBase;
  670. }
  671. #ifdef MULTIHEAP
  672. //+-------------------------------------------------------------------------
  673. //
  674. // Member: CSmAllocator::HeapName, public
  675. //
  676. // Synopsis: Return the luid part of the shared heap name
  677. //
  678. // History: 30-Nov-95 HenryLee Created
  679. //
  680. //--------------------------------------------------------------------------
  681. inline const ULONG CSmAllocator::GetHeapName()
  682. {
  683. return _ulHeapName;
  684. }
  685. #endif
  686. //+---------------------------------------------------------------------------
  687. //
  688. // Member: CHeapHeader::ResetAllocedBlocks, public
  689. //
  690. // Synopsis: Reset the allocated block counter
  691. //
  692. // History: 04-Apr-94 PhilipLa Created
  693. //
  694. //----------------------------------------------------------------------------
  695. inline void CHeapHeader::ResetAllocedBlocks(void)
  696. {
  697. _ulAllocedBlocks = 0;
  698. }
  699. //+---------------------------------------------------------------------------
  700. //
  701. // Member: CHeapHeader::IncrementAllocedBlocks, public
  702. //
  703. // Synopsis: Increment the allocated block count
  704. //
  705. // History: 04-Apr-94 PhilipLa Created
  706. //
  707. //----------------------------------------------------------------------------
  708. inline SIZE_T CHeapHeader::IncrementAllocedBlocks(void)
  709. {
  710. return ++_ulAllocedBlocks;
  711. }
  712. //+---------------------------------------------------------------------------
  713. //
  714. // Member: CHeapHeader::DecrementAllocedBlocks, public
  715. //
  716. // Synopsis: Decrement the allocated block count
  717. //
  718. // History: 04-Apr-94 PhilipLa Created
  719. //
  720. //----------------------------------------------------------------------------
  721. inline SIZE_T CHeapHeader::DecrementAllocedBlocks(void)
  722. {
  723. return --_ulAllocedBlocks;
  724. }
  725. //+---------------------------------------------------------------------------
  726. //
  727. // Member: CHeapHeader::GetAllocedBlocks, public
  728. //
  729. // Synopsis: Return the allocated block count
  730. //
  731. // History: 04-Apr-94 PhilipLa Created
  732. //
  733. //----------------------------------------------------------------------------
  734. inline SIZE_T CHeapHeader::GetAllocedBlocks(void)
  735. {
  736. return _ulAllocedBlocks;
  737. }
  738. #endif // !defined(_CHICAGO_)
  739. #endif // #ifndef __HEAP_HXX__