2 * ===============================================================
3 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
4 * ===============================================================
6 * This file is not open source and may not be copied without explicit
7 * written permission of AlliedModders LLC. This file may not be redistributed
8 * in whole or significant part.
9 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
16 #include "sm_memtable.h"
18 BaseMemTable::BaseMemTable(unsigned int init_size)
20 membase = (unsigned char *)malloc(init_size);
25 BaseMemTable::~BaseMemTable()
31 int BaseMemTable::CreateMem(unsigned int addsize, void **addr)
35 while (tail + addsize >= size)
38 membase = (unsigned char *)realloc(membase, size);
45 *addr = (void *)&membase[idx];
51 void *BaseMemTable::GetAddress(int index)
53 if (index < 0 || (unsigned int)index >= tail)
58 return &membase[index];
61 void BaseMemTable::Reset()
66 BaseStringTable::BaseStringTable(unsigned int init_size) : m_table(init_size)
70 BaseStringTable::~BaseStringTable()
74 int BaseStringTable::AddString(const char *string)
76 size_t len = strlen(string) + 1;
80 idx = m_table.CreateMem(len, (void **)&addr);
86 /*const char *BaseStringTable::GetString(int str)
88 return (const char *)m_table.GetAddress(str);
91 void BaseStringTable::Reset()