From bd8dcb97354bc29050e5aefe957c651bf2fedd07 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 3 Apr 2012 01:27:27 +0200 Subject: Keep list of strings allocated by the lexer --- src/fastd.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/fastd.h') diff --git a/src/fastd.h b/src/fastd.h index 5e62fb0..f402be8 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -132,6 +132,11 @@ struct _fastd_context { unsigned int randseed; }; +struct _fastd_config_str { + fastd_config_str *next; + char str[]; +}; + void fastd_printf(const fastd_context *ctx, const char *format, ...); void fastd_read_config_dir(fastd_context *ctx, fastd_config *conf, const char *dir, int depth); @@ -225,6 +230,22 @@ static inline size_t fastd_max_packet_size(const fastd_context *ctx) { } } +static inline fastd_config_str* fastd_config_str_dup(const char *str) { + fastd_config_str *ret = malloc(sizeof(fastd_config_str) + strlen(str) + 1); + ret->next = NULL; + strcpy(ret->str, str); + + return ret; +} + +static inline void fastd_config_str_free(fastd_config_str *str) { + while(str) { + fastd_config_str *next = str->next; + free(str); + str = next; + } +} + static inline bool timespec_after(const struct timespec *tp1, const struct timespec *tp2) { return (tp1->tv_sec > tp2->tv_sec || (tp1->tv_sec == tp2->tv_sec && tp1->tv_nsec > tp2->tv_nsec)); -- cgit v1.2.3