windows-nt/Source/XPSP1/NT/public/internal/windows/inc/duser/duisballoc.h

54 lines
879 B
C
Raw Permalink Normal View History

2020-09-26 03:20:57 -05:00
/*
* Fixed-Size Small Block Allocator
*/
#ifndef DUI_BASE_SBALLOC_H_INCLUDED
#define DUI_BASE_SBALLOC_H_INCLUDED
#pragma once
#include "duialloc.h"
namespace DirectUI
{
#define SBALLOC_FILLCHAR 0xFE
struct ISBLeak // Leak detector, not ref counted
{
virtual void AllocLeak(void* pBlock) = 0;
};
struct SBSection
{
SBSection* pNext;
BYTE* pData;
};
class SBAlloc
{
public:
static HRESULT Create(UINT uBlockSize, UINT uBlocksPerSection, ISBLeak* pisbLeak, SBAlloc** ppSBA);
void Destroy();
void* Alloc();
void Free(void* pBlock);
SBAlloc() { }
virtual ~SBAlloc();
private:
bool _FillStack();
UINT _uBlockSize;
UINT _uBlocksPerSection;
SBSection* _pSections;
BYTE** _ppStack; // Free block cache
int _dStackPtr;
ISBLeak* _pisbLeak;
};
} // namespace DirectUI
#endif // DUI_BASE_SBALLOC_H_INCLUDED