(svn r20951) -Codechange: Add SmallMap::Contains() and use it.

This commit is contained in:
frosch
2010-10-16 20:34:43 +00:00
parent 82d4ffacff
commit 98250ad8da
5 changed files with 16 additions and 5 deletions

View File

@@ -307,7 +307,8 @@ SQInteger AIInfo::AddLabels(HSQUIRRELVM vm)
int key = atoi(key_string + 1);
const char *label = SQ2OTTD(sq_label);
if (config->labels->Find(key) == config->labels->End()) config->labels->Insert(key, strdup(label));
/* !Contains() prevents strdup from leaking. */
if (!config->labels->Contains(key)) config->labels->Insert(key, strdup(label));
sq_pop(vm, 2);
}