Browse Source

Simplify include structure of container.[ch]

Nick Mathewson 5 years ago
parent
commit
f95e3bf5fc
6 changed files with 22 additions and 18 deletions
  1. 1 1
      src/common/address.h
  2. 11 2
      src/common/container.c
  3. 10 2
      src/common/container.h
  4. 0 11
      src/common/util.c
  5. 0 1
      src/common/util.h
  6. 0 1
      src/common/util_bug.c

+ 1 - 1
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) */
-

+ 11 - 2
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.

+ 10 - 2
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) */
-

+ 0 - 11
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.
  */

+ 0 - 1
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);

+ 0 - 1
src/common/util_bug.c

@@ -116,4 +116,3 @@ tor_bug_occurred_(const char *fname, unsigned int line,
   }
 #endif
 }
-