MCPcopy Create free account
hub / github.com/Farama-Foundation/ViZDoom / SetString

Method SetString

src/vizdoom/src/stringtable.cpp:403–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

401}
402
403void FStringTable::SetString (const char *name, const char *newString)
404{
405 StringEntry **pentry, *oentry;
406 FindString (name, pentry, oentry);
407
408 size_t newlen = strlen (newString);
409 size_t namelen = strlen (name);
410
411 // Create a new string entry
412 StringEntry *entry = (StringEntry *)M_Malloc (sizeof(*entry) + newlen + namelen + 2);
413 strcpy (entry->String, newString);
414 strcpy (entry->Name = entry->String + newlen + 1, name);
415 entry->PassNum = 0;
416
417 // If this is a new string, insert it. Otherwise, replace the old one.
418 if (oentry == NULL)
419 {
420 entry->Next = *pentry;
421 *pentry = entry;
422 }
423 else
424 {
425 *pentry = entry;
426 entry->Next = oentry->Next;
427 M_Free (oentry);
428 }
429}

Callers 3

PatchMusicFunction · 0.45
PatchTextFunction · 0.45
PatchStringsFunction · 0.45

Calls 2

M_MallocFunction · 0.85
M_FreeFunction · 0.85

Tested by

no test coverage detected