summaryrefslogtreecommitdiff
path: root/src/common/util.h
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-12-13 01:42:44 +0000
committerRoger Dingledine <arma@torproject.org>2003-12-13 01:42:44 +0000
commit1ae84fcbc1d7ae02a00c749eeaa22d5b5f1fa722 (patch)
tree595b1c933eea06e76900a286bdf88a2c8005a65d /src/common/util.h
parent9c66e2bf9a9ced671a18c967d08f8a2320105bbe (diff)
downloadtor-1ae84fcbc1d7ae02a00c749eeaa22d5b5f1fa722.tar.gz
tor-1ae84fcbc1d7ae02a00c749eeaa22d5b5f1fa722.zip
add a 'smartlist' building block that picks random elements from a list
svn:r897
Diffstat (limited to 'src/common/util.h')
-rw-r--r--src/common/util.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/common/util.h b/src/common/util.h
index bc8ee06c6f..b540181ff4 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -39,6 +39,18 @@ char *tor_strdup(const char *s);
char *tor_strndup(const char *s, size_t n);
#define tor_free(p) do {if(p) {free(p); (p)=NULL;}} while(0)
+typedef struct {
+ void **list;
+ int num_used;
+ int max;
+} smartlist_t;
+
+smartlist_t *smartlist_create(int max_elements);
+void smartlist_free(smartlist_t *sl);
+void smartlist_add(smartlist_t *sl, void *element);
+void smartlist_remove(smartlist_t *sl, void *element);
+void *smartlist_choose(smartlist_t *sl);
+
const char *eat_whitespace(const char *s);
const char *eat_whitespace_no_nl(const char *s);
const char *find_whitespace(const char *s);