eliminate leak from duplicate call to test_create_buildingtype

This commit is contained in:
Enno Rehling 2015-10-14 12:21:13 +02:00
parent ae3210ec87
commit 8e9e9c9c0f
1 changed files with 13 additions and 9 deletions

View File

@ -155,15 +155,19 @@ building_type * test_create_buildingtype(const char * name)
building_type *btype = bt_get_or_create(name);
btype->flags = BTF_NAMECHANGE;
btype->_name = _strdup(name);
btype->construction = (construction *)calloc(sizeof(construction), 1);
btype->construction->skill = SK_BUILDING;
btype->construction->maxsize = -1;
btype->construction->minskill = 1;
btype->construction->reqsize = 1;
btype->construction->materials = (requirement *)calloc(sizeof(requirement), 2);
btype->construction->materials[1].number = 0;
btype->construction->materials[0].number = 1;
btype->construction->materials[0].rtype = get_resourcetype(R_STONE);
if (!btype->construction) {
btype->construction = (construction *)calloc(sizeof(construction), 1);
btype->construction->skill = SK_BUILDING;
btype->construction->maxsize = -1;
btype->construction->minskill = 1;
btype->construction->reqsize = 1;
}
if (!btype->construction->materials) {
btype->construction->materials = (requirement *)calloc(sizeof(requirement), 2);
btype->construction->materials[1].number = 0;
btype->construction->materials[0].number = 1;
btype->construction->materials[0].rtype = get_resourcetype(R_STONE);
}
if (default_locale) {
locale_setstring(default_locale, name, name);
}