MCPcopy Create free account
hub / github.com/JACoders/OpenJK / Alloc

Method Alloc

code/qcommon/hstring.cpp:339–365  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

337 }
338
339 char *Alloc(int sizeBytes,int &id)
340 {
341 // Can't alloc more than MAX_HSTRINGS.
342 assert(mNextStringId<MAX_HSTRINGS);
343 char *raw=0;
344 if (mLastBlockNum>=0)
345 {
346 // Get the pointer to the start of allocated space in the current block.
347 raw=mBlockVec[mLastBlockNum]->Alloc(sizeBytes);
348 }
349 if(!raw)
350 {
351 // Ok, make a new empty block and append it.
352 CHSBlock *block=new(CHSBlock);
353 mBlockVec.push_back(block);
354 mLastBlockNum++;
355 raw=mBlockVec[mLastBlockNum]->Alloc(sizeBytes);
356 }
357 // Should never really happen!!
358 assert(raw);
359
360 id=mNextStringId;
361 gCharPtrs[mNextStringId]=raw;
362 mNextStringId++;
363
364 return(raw);
365 }
366
367 bool operator== (const CPool &pool) const
368 {

Callers

nothing calls this directly

Calls 2

AllocMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected