| 401 | } |
| 402 | |
| 403 | void 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 | } |
no test coverage detected