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

Method Init

code/qcommon/hstring.cpp:465–494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

463//
464
465void hstring::Init(const char *str)
466{
467 if(!str)
468 {
469 mId=0;
470 return;
471 }
472 int hash=HashFunction(str);
473 int id=HashHelper().FindFirst(hash);
474 while (id)
475 {
476 assert(id>0&&id<ThePool().mNextStringId);
477 if (!strcmp(str,gCharPtrs[id]))
478 {
479 mId=id;
480 return;
481 }
482 id=HashHelper().FindNext();
483 }
484 char *raw=ThePool().Alloc(strlen(str),mId);
485 strcpy(raw,str);
486 HashHelper().Add(hash,mId);
487#ifdef _DEBUG
488 int test;
489 raw=TheDebugPool().Alloc(strlen(str),test);
490 assert(test==mId);
491 strcpy(raw,str);
492#endif
493
494}
495
496const char *hstring::c_str(void) const
497{

Callers

nothing calls this directly

Calls 5

HashFunctionFunction · 0.85
FindFirstMethod · 0.80
FindNextMethod · 0.80
AllocMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected