summaryrefslogtreecommitdiff
path: root/src/lib/encoding/confline.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-06-13 15:19:26 -0400
committerNick Mathewson <nickm@torproject.org>2019-06-24 15:11:57 -0400
commit5a2ab886baaa125fe715acca8f7daf35031855aa (patch)
tree550aee0ea734185bb0ee64d0de4d3770ab1f1d8f /src/lib/encoding/confline.c
parent458da8a80d356a0c8015f025828cd1523838ecac (diff)
downloadtor-5a2ab886baaa125fe715acca8f7daf35031855aa.tar.gz
tor-5a2ab886baaa125fe715acca8f7daf35031855aa.zip
Add a function to append an existing line to a config line list.
We had an existing function to do this, but it took a pair of strings rather than a line.
Diffstat (limited to 'src/lib/encoding/confline.c')
-rw-r--r--src/lib/encoding/confline.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/lib/encoding/confline.c b/src/lib/encoding/confline.c
index fdb575e03f..b36e83dcc6 100644
--- a/src/lib/encoding/confline.c
+++ b/src/lib/encoding/confline.c
@@ -33,14 +33,23 @@ config_line_append(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 = NULL;
+
+ config_line_append_line(lst, newline);
+}
+
+/** Helper: append <b>newline</b> to the end of <b>lst</b>. */
+void
+config_line_append_line(config_line_t **lst,
+ config_line_t *newline)
+{
+ tor_assert(lst);
+
while (*lst)
lst = &((*lst)->next);
@@ -256,7 +265,7 @@ config_lines_dup_and_filter(const config_line_t *inp,
/** Return true iff a and b contain identical keys and values in identical
* order. */
int
-config_lines_eq(config_line_t *a, config_line_t *b)
+config_lines_eq(const config_line_t *a, const config_line_t *b)
{
while (a && b) {
if (strcasecmp(a->key, b->key) || strcmp(a->value, b->value))