leak: do not create new message_type objects in test_cleanup

This commit is contained in:
Enno Rehling 2015-10-15 08:29:20 +02:00
parent d79745812a
commit d4655ee88a
4 changed files with 7 additions and 9 deletions

View File

@ -1597,10 +1597,6 @@ void kernel_init(void)
{
register_reports();
mt_clear();
if (!mt_find("missing_message")) {
mt_register(mt_new_va("missing_message", "name:string", 0));
mt_register(mt_new_va("missing_feedback", "unit:unit", "region:region", "command:order", "name:string", 0));
}
attrib_init();
translation_init();
}

View File

@ -157,6 +157,6 @@ CuSuite *get_curse_suite(void)
SUITE_ADD_TEST(suite, test_good_dreams);
SUITE_ADD_TEST(suite, test_bad_dreams);
SUITE_ADD_TEST(suite, test_memstream);
DISABLE_TEST(suite, test_write_flag);
SUITE_ADD_TEST(suite, test_write_flag);
return suite;
}

View File

@ -91,6 +91,9 @@ struct message *msg_feedback(const struct unit *u, struct order *ord,
if (!mtype) {
log_error("trying to create message of unknown type \"%s\"\n", name);
if (!mt_find("missing_feedback")) {
mt_register(mt_new_va("missing_feedback", "unit:unit", "region:region", "command:order", "name:string", 0));
}
return msg_message("missing_feedback", "unit region command name", u,
u->region, ord, name);
}
@ -154,6 +157,9 @@ message *msg_message(const char *name, const char *sig, ...)
if (!mtype) {
log_warning("trying to create message of unknown type \"%s\"\n", name);
if (strcmp(name, "missing_message") != 0) {
if (!mt_find("missing_message")) {
mt_register(mt_new_va("missing_message", "name:string", 0));
}
return msg_message("missing_message", "name", name);
}
return NULL;

View File

@ -97,10 +97,6 @@ void test_cleanup(void)
for (i = 0; i != MAXKEYWORDS; ++i) {
enable_keyword(i, true);
}
if (!mt_find("missing_message")) {
mt_register(mt_new_va("missing_message", "name:string", 0));
mt_register(mt_new_va("missing_feedback", "unit:unit", "region:region", "command:order", "name:string", 0));
}
if (errno) {
int error = errno;
errno = 0;