Remove memtables from HandleSys (bug 5899 part 5, r=fyren).

This commit is contained in:
David Anderson 2013-08-31 19:50:36 -07:00
parent b917c540aa
commit 2dae228f10
2 changed files with 18 additions and 30 deletions

View File

@ -59,8 +59,6 @@ HandleSystem::HandleSystem()
m_Types = new QHandleType[HANDLESYS_TYPEARRAY_SIZE];
memset(m_Types, 0, sizeof(QHandleType) * HANDLESYS_TYPEARRAY_SIZE);
m_strtab = new BaseStringTable(512);
m_TypeTail = 0;
}
@ -68,7 +66,6 @@ HandleSystem::~HandleSystem()
{
delete [] m_Handles;
delete [] m_Types;
delete m_strtab;
}
@ -142,12 +139,10 @@ HandleType_t HandleSystem::CreateType(const char *name,
if (name && name[0] != '\0')
{
if (m_TypeLookup.retrieve(name))
if (m_TypeLookup.contains(name))
{
if (err)
{
*err = HandleError_Parameter;
}
return 0;
}
}
@ -209,10 +204,10 @@ HandleType_t HandleSystem::CreateType(const char *name,
pType->dispatch = dispatch;
if (name && name[0] != '\0')
{
pType->nameIdx = m_strtab->AddString(name);
pType->name = name;
m_TypeLookup.insert(name, pType);
} else {
pType->nameIdx = -1;
pType->name.setVoid();
}
pType->opened = 0;
@ -930,13 +925,8 @@ bool HandleSystem::RemoveType(HandleType_t type, IdentityToken_t *ident)
}
/* Remove it from the type cache. */
if (pType->nameIdx != -1)
{
const char *typeName;
typeName = m_strtab->GetString(pType->nameIdx);
m_TypeLookup.remove(typeName);
}
if (!pType->name.isVoid())
m_TypeLookup.remove(pType->name.chars());
return true;
}
@ -1061,14 +1051,10 @@ bool HandleSystem::TryAndFreeSomeHandles()
continue; /* We may have gaps, it's fine. */
}
if (m_Types[i].nameIdx != -1)
{
pTypeName = m_strtab->GetString(m_Types[i].nameIdx);
}
if (!m_Types[i].name.isVoid())
pTypeName = m_Types[i].name.chars();
else
{
pTypeName = "ANON";
}
HANDLE_LOG_VERY_BAD("Type\t%-20.20s|\tCount\t%u", pTypeName, pCount[i]);
}
@ -1133,10 +1119,8 @@ void HandleSystem::Dump(HANDLE_REPORTER rep)
unsigned int size = 0;
unsigned int parentIdx;
bool bresult;
if (pType->nameIdx != -1)
{
type = m_strtab->GetString(pType->nameIdx);
}
if (!pType->name.isVoid())
type = pType->name.chars();
if ((parentIdx = m_Handles[i].clone) != 0)
{

View File

@ -34,8 +34,8 @@
#include <IHandleSys.h>
#include <stdio.h>
#include <sm_stringhashmap.h>
#include "sm_memtable.h"
#include <sm_namehashset.h>
#include <am-string.h>
#include "common_logic.h"
#define HANDLESYS_MAX_HANDLES (1<<14)
@ -103,7 +103,12 @@ struct QHandleType
TypeAccess typeSec;
HandleAccess hndlSec;
unsigned int opened;
int nameIdx;
ke::AString name;
static inline bool matches(const char *key, const QHandleType *type)
{
return type->name.compare(key) == 0;
}
};
typedef void (HANDLE_REPORTER)(const char *str, ...);
@ -216,13 +221,12 @@ protected:
private:
QHandle *m_Handles;
QHandleType *m_Types;
StringHashMap<QHandleType *> m_TypeLookup;
NameHashSet<QHandleType *> m_TypeLookup;
unsigned int m_TypeTail;
unsigned int m_FreeTypes;
unsigned int m_HandleTail;
unsigned int m_FreeHandles;
unsigned int m_HSerial;
BaseStringTable *m_strtab;
};
extern HandleSystem g_HandleSys;