]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add implementation of smartlist_add_strdup
authorovercaffeinated <overcaffeinated@airmail.cc>
Thu, 27 Oct 2016 09:12:28 +0000 (10:12 +0100)
committerovercaffeinated <overcaffeinated@airmail.cc>
Thu, 27 Oct 2016 09:12:28 +0000 (10:12 +0100)
Add smartlist_add_strdup(sl, string) - replaces the use of
smartlist_add(sl, tor_strdup(string)). Fixes bug 20048.

changes/bug20048 [new file with mode: 0644]
src/common/util.c
src/common/util.h

diff --git a/changes/bug20048 b/changes/bug20048
new file mode 100644 (file)
index 0000000..0874e97
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor bugfixes:
+    - Implement smartlist_add_strdup() function. Replaces the use of
+      smartlist_add(sl, tor_strdup(str)). Fixes bug 20048. 
+
index 916296790781827e5819b4c5dabb73500bcc25cb..02ccf4ff0fef1f29ac90c1a2d221a13aaaab23b4 100644 (file)
@@ -3532,6 +3532,17 @@ smartlist_add_vasprintf(struct smartlist_t *sl, const char *pattern,
   smartlist_add(sl, str);
 }
 
+/** Append a copy of string to sl */
+void
+smartlist_add_strdup(struct smartlist_t *sl, const char *string)
+{
+  char *copy;
+
+  copy = tor_strdup(string);
+
+  smartlist_add(sl, copy);
+}
+
 /** Return a new list containing the filenames in the directory <b>dirname</b>.
  * Return NULL on error or if <b>dirname</b> is not a directory.
  */
index 479fc8d610e5e1b7a9a24fae2b46f2ecd8011589..37f4bed1cb40c228edfcf255915f1f2bfc3cbf06 100644 (file)
@@ -239,6 +239,7 @@ void smartlist_add_asprintf(struct smartlist_t *sl, const char *pattern, ...)
 void smartlist_add_vasprintf(struct smartlist_t *sl, const char *pattern,
                              va_list args)
   CHECK_PRINTF(2, 0);
+void smartlist_add_strdup(struct smartlist_t *sl, const char *string);
 
 /* Time helpers */
 long tv_udiff(const struct timeval *start, const struct timeval *end);