commit f95e3bf5fc4e2d5fef42b86d81f155c00b1983ac Author: Nick Mathewson nickm@torproject.org Date: Thu Jun 21 15:33:25 2018 -0400
Simplify include structure of container.[ch] --- src/common/address.h | 2 +- src/common/container.c | 13 +++++++++++-- src/common/container.h | 12 ++++++++++-- src/common/util.c | 11 ----------- src/common/util.h | 1 - src/common/util_bug.c | 1 - 6 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/src/common/address.h b/src/common/address.h index 317c7f329..6986143f6 100644 --- a/src/common/address.h +++ b/src/common/address.h @@ -16,6 +16,7 @@ #include "lib/cc/torint.h" #include "common/compat.h" #include "common/container.h" +#include "common/util_bug.h"
#ifdef ADDRESS_PRIVATE
@@ -376,4 +377,3 @@ STATIC smartlist_t *get_interface_addresses_ioctl(int severity, #endif /* defined(ADDRESS_PRIVATE) */
#endif /* !defined(TOR_ADDRESS_H) */ - diff --git a/src/common/container.c b/src/common/container.c index c30e84ba2..a7810ba90 100644 --- a/src/common/container.c +++ b/src/common/container.c @@ -11,9 +11,7 @@ * a digest-to-void* map. **/
-#include "common/compat.h" #include "common/util.h" -#include "common/torlog.h" #include "common/container.h" #include "lib/crypt_ops/crypto_digest.h"
@@ -113,6 +111,17 @@ smartlist_add_all(smartlist_t *s1, const smartlist_t *s2) s1->num_used = (int) new_size; }
+/** 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); +} + /** Remove all elements E from sl such that E==element. Preserve * the order of any elements before E, but elements after E can be * rearranged. diff --git a/src/common/container.h b/src/common/container.h index 372fa6640..c45bfc359 100644 --- a/src/common/container.h +++ b/src/common/container.h @@ -6,7 +6,15 @@ #ifndef TOR_CONTAINER_H #define TOR_CONTAINER_H
-#include "common/util.h" +#include <stddef.h> +#include <stdlib.h> +#include <string.h> + +#include "lib/cc/compat_compiler.h" +#include "lib/cc/torint.h" +#include "lib/testsupport/testsupport.h" +#include "lib/malloc/util_malloc.h" +#include "common/util_bug.h" #include "siphash.h"
/** A resizeable list of pointers, with associated helpful functionality. @@ -34,6 +42,7 @@ MOCK_DECL(void, smartlist_free_, (smartlist_t *sl)); void smartlist_clear(smartlist_t *sl); void smartlist_add(smartlist_t *sl, void *element); void smartlist_add_all(smartlist_t *sl, const smartlist_t *s2); +void smartlist_add_strdup(struct smartlist_t *sl, const char *string); void smartlist_remove(smartlist_t *sl, const void *element); void smartlist_remove_keeporder(smartlist_t *sl, const void *element); void *smartlist_pop_last(smartlist_t *sl); @@ -739,4 +748,3 @@ third_quartile_uint32(uint32_t *array, int n_elements) }
#endif /* !defined(TOR_CONTAINER_H) */ - diff --git a/src/common/util.c b/src/common/util.c index d09d19415..fbb2fed39 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -3279,17 +3279,6 @@ 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. */ diff --git a/src/common/util.h b/src/common/util.h index bc29ddbe2..1c889082b 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -167,7 +167,6 @@ 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); diff --git a/src/common/util_bug.c b/src/common/util_bug.c index 5cfd00649..524d48c68 100644 --- a/src/common/util_bug.c +++ b/src/common/util_bug.c @@ -116,4 +116,3 @@ tor_bug_occurred_(const char *fname, unsigned int line, } #endif } -