Ejemplo n.º 1
0
void hstring::Init(const char *str)
{
	if(!str)
	{
		mId=0;
		return;
	}
	int hash=HashFunction(str);
	int id=HashHelper().FindFirst(hash);
	while (id)
	{
		assert(id>0&&id<ThePool().mNextStringId);
		if (!strcmp(str,gCharPtrs[id]))
		{
			mId=id;
			return;
		}
		id=HashHelper().FindNext();
	}
	char *raw=ThePool().Alloc(strlen(str),mId);
	strcpy(raw,str);
	HashHelper().Add(hash,mId);
#ifdef _DEBUG
	int test;
	raw=TheDebugPool().Alloc(strlen(str),test);
	assert(test==mId);
	strcpy(raw,str);
#endif

}
Ejemplo n.º 2
0
string hstring::str(void) const
{
    if(!mId)
    {
        return(string());
    }
    assert(mId>0&&mId<ThePool().mNextStringId);
    return string(gCharPtrs[mId]);
}
Ejemplo n.º 3
0
const char *hstring::c_str(void) const
{
    if(!mId)
    {
        return("");
    }
    assert(mId>0&&mId<ThePool().mNextStringId);
    return(gCharPtrs[mId]);
}
Ejemplo n.º 4
0
    ~CPoolChecker()
    {
#if 0
        int i;
        for (i=1; i<ThePool().mNextStringId; i++)
        {
            OutputDebugString(gCharPtrs[i]);
            OutputDebugString("\n");
        }
#endif
#if _DEBUG
        char mess[1000];
#if _GAME
        sprintf(mess,"[MEM][GAME]  String Pool %d unique strings, %dK\n",ThePool().mNextStringId,(ThePool().mLastBlockNum+1)*BLOCK_SIZE/1024);
#elif _CGAME
        sprintf(mess,"[MEM][CGAME]  String Pool %d unique strings, %dK\n",ThePool().mNextStringId,(ThePool().mLastBlockNum+1)*BLOCK_SIZE/1024);
#else
        sprintf(mess,"[MEM][EXE]  String Pool %d unique strings, %dK\n",ThePool().mNextStringId,(ThePool().mLastBlockNum+1)*BLOCK_SIZE/1024);
#endif
        OutputDebugString(mess);
#endif
        // if this fails it means the string storage is CORRUPTED, let someone know
        assert(TheDebugPool()==ThePool());
    }
Ejemplo n.º 5
0
void TouchStringPool(void)
{
    ThePool().TouchMem();
    HashHelper().TouchMem();
}
Ejemplo n.º 6
0
 CPoolChecker()
 {
     TheDebugPool();
     ThePool();
 }