void NetStringTable::repack() { DataChunker *newAllocator = new DataChunker(DataChunkerSize); for(U32 walk = firstValid; walk; walk = table[walk].link) { const char *prevStr = table[walk].string; table[walk].string = (char *) newAllocator->alloc(dStrlen(prevStr) + 1); dStrcpy(table[walk].string, prevStr); } delete allocator; allocator = newAllocator; }
CollisionWorkingList* CollisionWorkingList::alloc() { if (sFreeList.wLink.mNext != &sFreeList) { CollisionWorkingList* nxt = sFreeList.wLink.mNext; nxt->unlink(); return nxt; } return constructInPlace((CollisionWorkingList*)sChunker.alloc(sizeof(CollisionWorkingList))); }
CollisionStateList* CollisionStateList::alloc() { if (!sFreeList.isEmpty()) { CollisionStateList* nxt = sFreeList.mNext; nxt->unlink(); nxt->mState = NULL; return nxt; } return constructInPlace((CollisionStateList*)sChunker.alloc(sizeof(CollisionStateList))); }
namespace Compiler { F64 consoleStringToNumber(const char *str, StringTableEntry file, U32 line) { F64 val = dAtof(str); if(val != 0) return val; else if(!dStricmp(str, "true")) return 1; else if(!dStricmp(str, "false")) return 0; else if(file) { Con::warnf(ConsoleLogEntry::General, "%s (%d): string always evaluates to 0.", file, line); return 0; } return 0; } //------------------------------------------------------------ CompilerStringTable *gCurrentStringTable, gGlobalStringTable, gFunctionStringTable; CompilerFloatTable *gCurrentFloatTable, gGlobalFloatTable, gFunctionFloatTable; DataChunker gConsoleAllocator; CompilerIdentTable gIdentTable; CodeBlock *gCurBreakBlock; //------------------------------------------------------------ CodeBlock *getBreakCodeBlock() { return gCurBreakBlock; } void setBreakCodeBlock(CodeBlock *cb) { gCurBreakBlock = cb; } //------------------------------------------------------------ U32 evalSTEtoU32(StringTableEntry ste, U32) { return *((U32 *) &ste); } U32 compileSTEtoU32(StringTableEntry ste, U32 ip) { if(ste) getIdentTable().add(ste, ip); return 0; } U32 (*STEtoU32)(StringTableEntry ste, U32 ip) = evalSTEtoU32; //------------------------------------------------------------ bool gSyntaxError = false; //------------------------------------------------------------ CompilerStringTable *getCurrentStringTable() { return gCurrentStringTable; } CompilerStringTable &getGlobalStringTable() { return gGlobalStringTable; } CompilerStringTable &getFunctionStringTable() { return gFunctionStringTable; } void setCurrentStringTable (CompilerStringTable* cst) { gCurrentStringTable = cst; } CompilerFloatTable *getCurrentFloatTable() { return gCurrentFloatTable; } CompilerFloatTable &getGlobalFloatTable() { return gGlobalFloatTable; } CompilerFloatTable &getFunctionFloatTable() { return gFunctionFloatTable; } void setCurrentFloatTable (CompilerFloatTable* cst) { gCurrentFloatTable = cst; } CompilerIdentTable &getIdentTable() { return gIdentTable; } void precompileIdent(StringTableEntry ident) { if(ident) gGlobalStringTable.add(ident); } void resetTables() { setCurrentStringTable(&gGlobalStringTable); setCurrentFloatTable(&gGlobalFloatTable); getGlobalFloatTable().reset(); getGlobalStringTable().reset(); getFunctionFloatTable().reset(); getFunctionStringTable().reset(); getIdentTable().reset(); } void *consoleAlloc(U32 size) { return gConsoleAllocator.alloc(size); } void consoleAllocReset() { gConsoleAllocator.freeBlocks(); } }
void consoleAllocReset() { gConsoleAllocator.freeBlocks(); }
void *consoleAlloc(U32 size) { return gConsoleAllocator.alloc(size); }