commit 222122450c1e879989c440088c01eaa95e4d6980 Author: Nick Mathewson nickm@torproject.org Date: Thu Apr 6 14:18:50 2017 -0400
Add a config_line_prepend() function --- src/common/confline.c | 18 ++++++++++++++++++ src/common/confline.h | 2 ++ 2 files changed, 20 insertions(+)
diff --git a/src/common/confline.c b/src/common/confline.c index 36f4c87..d4468f8 100644 --- a/src/common/confline.c +++ b/src/common/confline.c @@ -30,6 +30,24 @@ config_line_append(config_line_t **lst, (*lst) = newline; }
+/** Helper: allocate a new configuration option mapping 'key' to 'val', + * and prepend it to *<b>lst</b> */ +void +config_line_prepend(config_line_t **lst, + const char *key, + const char *val) +{ + tor_assert(lst); + + config_line_t *newline; + + newline = tor_malloc_zero(sizeof(config_line_t)); + newline->key = tor_strdup(key); + newline->value = tor_strdup(val); + newline->next = *lst; + *lst = newline; +} + /** Return the first line in <b>lines</b> whose key is exactly <b>key</b>, or * NULL if no such key exists. * diff --git a/src/common/confline.h b/src/common/confline.h index c695bf6..477c692 100644 --- a/src/common/confline.h +++ b/src/common/confline.h @@ -31,6 +31,8 @@ typedef struct config_line_t {
void config_line_append(config_line_t **lst, const char *key, const char *val); +void config_line_prepend(config_line_t **lst, + const char *key, const char *val); config_line_t *config_lines_dup(const config_line_t *inp); config_line_t *config_lines_dup_and_filter(const config_line_t *inp, const char *key);
tor-commits@lists.torproject.org