mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-25 13:11:00 +00:00
[qfcc] Make save_string null-safe
It simply returns nullptr when the saved string is null.
This commit is contained in:
parent
628e3d2aed
commit
f2609b1a9b
1 changed files with 8 additions and 4 deletions
|
@ -139,12 +139,16 @@ ss_get_key (const void *s, void *unused)
|
|||
const char *
|
||||
save_string (const char *str)
|
||||
{
|
||||
char *s;
|
||||
if (!saved_strings)
|
||||
if (!str) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!saved_strings) {
|
||||
saved_strings = Hash_NewTable (16381, ss_get_key, 0, 0, 0);
|
||||
s = Hash_Find (saved_strings, str);
|
||||
if (s)
|
||||
}
|
||||
char *s = Hash_Find (saved_strings, str);
|
||||
if (s) {
|
||||
return s;
|
||||
}
|
||||
s = strdup (str);
|
||||
Hash_Add (saved_strings, s);
|
||||
return s;
|
||||
|
|
Loading…
Reference in a new issue