From 1050daac19d90bcc5ac5d288418e96cccf663f69 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 17 Dec 2014 17:40:36 +0100 Subject: [PATCH] remove strlist from config.c, move it to reports.c (where it is used primarily). this is not the best data structure there is, should replace it some day. --- src/kernel/config.c | 20 -------------------- src/kernel/config.h | 8 -------- src/reports.c | 20 ++++++++++++++++++++ src/reports.h | 9 +++++++++ 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/kernel/config.c b/src/kernel/config.c index 30f49a186..5063a4427 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -990,26 +990,6 @@ int getunit(const region * r, const faction * f, unit **uresult) return result; } -/* - String Listen --------------------------------------------- */ -void addstrlist(strlist ** SP, const char *s) -{ - strlist *slist = malloc(sizeof(strlist)); - slist->next = NULL; - slist->s = _strdup(s); - addlist(SP, slist); -} - -void freestrlist(strlist * s) -{ - strlist *q, *p = s; - while (p) { - q = p->next; - free(p->s); - free(p); - p = q; - } -} - /* - Namen der Strukturen -------------------------------------- */ char *untilde(char *ibuf) { diff --git a/src/kernel/config.h b/src/kernel/config.h index 9a44e7540..908f9b993 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -108,14 +108,6 @@ extern "C" { /* special units */ void make_undead_unit(struct unit *); - typedef struct strlist { - struct strlist *next; - char *s; - } strlist; - - void addstrlist(strlist ** SP, const char *s); - void freestrlist(strlist * s); - unsigned int atoip(const char *s); unsigned int getuint(void); int getint(void); diff --git a/src/reports.c b/src/reports.c index c01a49bf2..e478a0200 100644 --- a/src/reports.c +++ b/src/reports.c @@ -2406,6 +2406,26 @@ static void eval_int36(struct opstack **stack, const void *userdata) /*** END MESSAGE RENDERING ***/ +/* - String Listen --------------------------------------------- */ +void addstrlist(strlist ** SP, const char *s) +{ + strlist *slist = malloc(sizeof(strlist)); + slist->next = NULL; + slist->s = _strdup(s); + addlist(SP, slist); +} + +void freestrlist(strlist * s) +{ + strlist *q, *p = s; + while (p) { + q = p->next; + free(p->s); + free(p); + p = q; + } +} + #include static void log_orders(const struct message *msg) diff --git a/src/reports.h b/src/reports.h index cb4ab54f3..60019ac2f 100644 --- a/src/reports.h +++ b/src/reports.h @@ -142,6 +142,15 @@ extern "C" { size_t f_regionid(const struct region *r, const struct faction *f, char *buffer, size_t size); + typedef struct strlist { + struct strlist *next; + char *s; + } strlist; + + void addstrlist(strlist ** SP, const char *s); + void freestrlist(strlist * s); + + #define GR_PLURAL 0x01 /* grammar: plural */ #define MAX_INVENTORY 128 /* maimum number of different items in an inventory */ #define MAX_RAWMATERIALS 8 /* maximum kinds of raw materials in a regions */