diff --git a/src/kernel/terrain.c b/src/kernel/terrain.c index 2f5b677ea..6090f771c 100644 --- a/src/kernel/terrain.c +++ b/src/kernel/terrain.c @@ -63,6 +63,19 @@ const char *terraindata[MAXTERRAINS] = { static terrain_type *registered_terrains; +#ifndef DISABLE_TESTS +void test_clear_terrains(void) +{ + while (registered_terrains) { + terrain_type * t = registered_terrains; + registered_terrains = t->next; + free(t->_name); + free(t->production); + free(t); + } +} +#endif + const terrain_type *terrains(void) { return registered_terrains; diff --git a/src/kernel/terrain.h b/src/kernel/terrain.h index 64de714e7..fca223e01 100644 --- a/src/kernel/terrain.h +++ b/src/kernel/terrain.h @@ -67,7 +67,7 @@ extern "C" { struct terrain_production *production; const struct item_type **herbs; /* zero-terminated array of herbs */ const char *(*name) (const struct region * r); - const struct terrain_type *next; + struct terrain_type *next; } terrain_type; extern const terrain_type *terrains(void); @@ -77,6 +77,10 @@ extern "C" { extern void init_terrains(void); +#ifndef DISABLE_TESTS + void test_clear_terrains(void); +#endif + #ifdef __cplusplus } #endif