summaryrefslogtreecommitdiff
path: root/src/common/confline.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-04-06 14:18:50 -0400
committerNick Mathewson <nickm@torproject.org>2017-04-15 11:21:32 -0400
commit222122450c1e879989c440088c01eaa95e4d6980 (patch)
tree9266a96dffe2f1dd953124f27f54a3e27b772e3f /src/common/confline.c
parent06ecb9432f4596f10e73f82bb1ff6677060756f9 (diff)
downloadtor-222122450c1e879989c440088c01eaa95e4d6980.tar.gz
tor-222122450c1e879989c440088c01eaa95e4d6980.zip
Add a config_line_prepend() function
Diffstat (limited to 'src/common/confline.c')
-rw-r--r--src/common/confline.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/common/confline.c b/src/common/confline.c
index 36f4c875f3..d4468f80ea 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.
*