forked from github/server
it sucks that get_translations sometimes returns tokens, and sometimes critbit_trees. How is anyone supposed to free that correctly?
This commit is contained in:
parent
2fbb04140c
commit
e9c3a00f7d
|
@ -39,6 +39,7 @@ void test_updatespells(CuTest * tc)
|
||||||
CuAssertPtrNotNull(tc, f->spellbook);
|
CuAssertPtrNotNull(tc, f->spellbook);
|
||||||
CuAssertIntEquals(tc, 1, ql_length(f->spellbook->spells));
|
CuAssertIntEquals(tc, 1, ql_length(f->spellbook->spells));
|
||||||
CuAssertPtrNotNull(tc, spellbook_get(f->spellbook, sp));
|
CuAssertPtrNotNull(tc, spellbook_get(f->spellbook, sp));
|
||||||
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_spellbooks(CuTest * tc)
|
void test_spellbooks(CuTest * tc)
|
||||||
|
@ -63,12 +64,11 @@ void test_spellbooks(CuTest * tc)
|
||||||
entry = spellbook_get(herp, sp);
|
entry = spellbook_get(herp, sp);
|
||||||
CuAssertPtrNotNull(tc, entry);
|
CuAssertPtrNotNull(tc, entry);
|
||||||
CuAssertPtrEquals(tc, sp, entry->sp);
|
CuAssertPtrEquals(tc, sp, entry->sp);
|
||||||
/* CuAssertPtrEquals(tc, 0, spellbook_get(derp, sname)); */
|
|
||||||
|
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
herp = get_spellbook("herp");
|
herp = get_spellbook("herp");
|
||||||
CuAssertPtrNotNull(tc, herp);
|
CuAssertPtrNotNull(tc, herp);
|
||||||
/* CuAssertPtrEquals(tc, 0, spellbook_get(herp, sname)); */
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
static spell * test_magic_create_spell(void)
|
static spell * test_magic_create_spell(void)
|
||||||
|
@ -215,6 +215,7 @@ void test_getspell_faction(CuTest * tc)
|
||||||
f->spellbook = create_spellbook(0);
|
f->spellbook = create_spellbook(0);
|
||||||
spellbook_add(f->spellbook, sp, 1);
|
spellbook_add(f->spellbook, sp, 1);
|
||||||
CuAssertPtrEquals(tc, sp, unit_getspell(u, "Herp-a-derp", lang));
|
CuAssertPtrEquals(tc, sp, unit_getspell(u, "Herp-a-derp", lang));
|
||||||
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_getspell_school(CuTest * tc)
|
void test_getspell_school(CuTest * tc)
|
||||||
|
@ -246,6 +247,7 @@ void test_getspell_school(CuTest * tc)
|
||||||
CuAssertPtrNotNull(tc, book);
|
CuAssertPtrNotNull(tc, book);
|
||||||
spellbook_add(book, sp, 1);
|
spellbook_add(book, sp, 1);
|
||||||
CuAssertPtrEquals(tc, sp, unit_getspell(u, "Herp-a-derp", lang));
|
CuAssertPtrEquals(tc, sp, unit_getspell(u, "Herp-a-derp", lang));
|
||||||
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_set_pre_combatspell(CuTest * tc)
|
void test_set_pre_combatspell(CuTest * tc)
|
||||||
|
@ -278,6 +280,7 @@ void test_set_pre_combatspell(CuTest * tc)
|
||||||
unset_combatspell(u, sp);
|
unset_combatspell(u, sp);
|
||||||
CuAssertIntEquals(tc, 0, get_combatspelllevel(u, index));
|
CuAssertIntEquals(tc, 0, get_combatspelllevel(u, index));
|
||||||
CuAssertPtrEquals(tc, 0, (spell *)get_combatspell(u, index));
|
CuAssertPtrEquals(tc, 0, (spell *)get_combatspell(u, index));
|
||||||
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_set_main_combatspell(CuTest * tc)
|
void test_set_main_combatspell(CuTest * tc)
|
||||||
|
@ -310,6 +313,7 @@ void test_set_main_combatspell(CuTest * tc)
|
||||||
unset_combatspell(u, sp);
|
unset_combatspell(u, sp);
|
||||||
CuAssertIntEquals(tc, 0, get_combatspelllevel(u, index));
|
CuAssertIntEquals(tc, 0, get_combatspelllevel(u, index));
|
||||||
CuAssertPtrEquals(tc, 0, (spell *)get_combatspell(u, index));
|
CuAssertPtrEquals(tc, 0, (spell *)get_combatspell(u, index));
|
||||||
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_set_post_combatspell(CuTest * tc)
|
void test_set_post_combatspell(CuTest * tc)
|
||||||
|
@ -342,6 +346,7 @@ void test_set_post_combatspell(CuTest * tc)
|
||||||
unset_combatspell(u, sp);
|
unset_combatspell(u, sp);
|
||||||
CuAssertIntEquals(tc, 0, get_combatspelllevel(u, index));
|
CuAssertIntEquals(tc, 0, get_combatspelllevel(u, index));
|
||||||
CuAssertPtrEquals(tc, 0, (spell *)get_combatspell(u, index));
|
CuAssertPtrEquals(tc, 0, (spell *)get_combatspell(u, index));
|
||||||
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_hasspell(CuTest * tc)
|
void test_hasspell(CuTest * tc)
|
||||||
|
@ -371,6 +376,7 @@ void test_hasspell(CuTest * tc)
|
||||||
|
|
||||||
set_level(u, SK_MAGIC, 1);
|
set_level(u, SK_MAGIC, 1);
|
||||||
CuAssertTrue(tc, !u_hasspell(u, sp));
|
CuAssertTrue(tc, !u_hasspell(u, sp));
|
||||||
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
CuSuite *get_magic_suite(void)
|
CuSuite *get_magic_suite(void)
|
||||||
|
|
|
@ -242,6 +242,7 @@ void add_translation(struct critbit_tree **cbp, const char *key, int i) {
|
||||||
if (str) {
|
if (str) {
|
||||||
size_t len = strlen(str);
|
size_t len = strlen(str);
|
||||||
if (!cb) {
|
if (!cb) {
|
||||||
|
// TODO: this will leak, because we do not know how to clean it up */
|
||||||
*cbp = cb = (struct critbit_tree *)calloc(1, sizeof(struct critbit_tree *));
|
*cbp = cb = (struct critbit_tree *)calloc(1, sizeof(struct critbit_tree *));
|
||||||
}
|
}
|
||||||
len = cb_new_kv(str, len, &i, sizeof(int), buffer);
|
len = cb_new_kv(str, len, &i, sizeof(int), buffer);
|
||||||
|
|
|
@ -212,6 +212,7 @@ void freetokens(void * root)
|
||||||
for (i = 0; node && i != NODEHASHSIZE; ++i) {
|
for (i = 0; node && i != NODEHASHSIZE; ++i) {
|
||||||
if (node->next[i]) {
|
if (node->next[i]) {
|
||||||
freetokens(node->next[i]->node);
|
freetokens(node->next[i]->node);
|
||||||
|
free(node->next[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(node);
|
free(node);
|
||||||
|
|
Loading…
Reference in New Issue