forked from github/server
fix a lot of memory leaks that were exposed by unit tests.
This commit is contained in:
parent
71ced993e2
commit
30b0b2ad81
|
@ -991,6 +991,7 @@ void free_construction(struct construction *cons)
|
|||
{
|
||||
while (cons) {
|
||||
construction *next = cons->improvement;
|
||||
free(cons->name);
|
||||
free(cons->materials);
|
||||
free(cons);
|
||||
cons = next;
|
||||
|
|
|
@ -517,6 +517,7 @@ static int icache_size;
|
|||
#define ICACHE_MAX 100
|
||||
|
||||
void item_done(void) {
|
||||
icache_size = ICACHE_MAX;
|
||||
i_freeall(&icache);
|
||||
icache_size = 0;
|
||||
}
|
||||
|
@ -951,7 +952,7 @@ void write_items(struct storage *store, item * ilist)
|
|||
|
||||
static void free_itype(item_type *itype) {
|
||||
assert(itype);
|
||||
free(itype->construction);
|
||||
free_construction(itype->construction);
|
||||
free(itype->_appearance[0]);
|
||||
free(itype->_appearance[1]);
|
||||
free(itype);
|
||||
|
|
|
@ -27,11 +27,12 @@ static void test_resources(CuTest *tc) {
|
|||
rtype = rt_get_or_create("stone");
|
||||
CuAssertPtrEquals(tc, (void *)rtype, (void *)rt_find("stone"));
|
||||
CuAssertPtrEquals(tc, (void *)rtype, (void *)get_resourcetype(R_STONE));
|
||||
test_cleanup();
|
||||
free_resources();
|
||||
CuAssertPtrEquals(tc, 0, rt_find("stone"));
|
||||
CuAssertPtrEquals(tc, 0, rt_find("peasant"));
|
||||
rtype = rt_get_or_create("stone");
|
||||
CuAssertPtrEquals(tc, (void *)rtype, (void *)get_resourcetype(R_STONE));
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
CuSuite *get_tests_suite(void)
|
||||
|
|
|
@ -9,6 +9,7 @@ static void test_mt_new(CuTest *tc)
|
|||
message_type *mt;
|
||||
test_setup();
|
||||
mt = mt_new_va("test", "name:string", "number:int", NULL);
|
||||
mt_register(mt);
|
||||
CuAssertPtrNotNull(tc, mt);
|
||||
CuAssertStrEquals(tc, "test", mt->name);
|
||||
CuAssertIntEquals(tc, 2, mt->nparameters);
|
||||
|
|
Loading…
Reference in New Issue