summaryrefslogtreecommitdiff
path: root/src/common/container.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-10-19 18:56:28 +0000
committerNick Mathewson <nickm@torproject.org>2007-10-19 18:56:28 +0000
commitb0a18d1bfa90f41bb03d5843baeab3b3f1207a2c (patch)
tree54ed8679ef1cc2ff9e776356c1f14441b1094170 /src/common/container.c
parent6ca4eebb57ef0b893240f8256a6364be5036804d (diff)
downloadtor-b0a18d1bfa90f41bb03d5843baeab3b3f1207a2c.tar.gz
tor-b0a18d1bfa90f41bb03d5843baeab3b3f1207a2c.zip
r15967@catbus: nickm | 2007-10-19 14:14:47 -0400
Change meaning of "freefn" argument to smartlist_uniq so that we can remove duplicates from a list without freeing them. svn:r12053
Diffstat (limited to 'src/common/container.c')
-rw-r--r--src/common/container.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/common/container.c b/src/common/container.c
index f2a80208b3..3432bd084b 100644
--- a/src/common/container.c
+++ b/src/common/container.c
@@ -471,8 +471,7 @@ smartlist_sort(smartlist_t *sl, int (*compare)(const void **a, const void **b))
/** Given a sorted smartlist <b>sl</b> and the comparison function used to
* sort it, remove all duplicate members. If free_fn is provided, calls
- * free_fn on each duplicate. Otherwise, frees them with tor_free(), which
- * may not be what you want.. Preserves order.
+ * free_fn on each duplicate. Otherwise, just removes them. Preserves order.
*/
void
smartlist_uniq(smartlist_t *sl,
@@ -485,8 +484,6 @@ smartlist_uniq(smartlist_t *sl,
(const void **)&(sl->list[i])) == 0) {
if (free_fn)
free_fn(sl->list[i]);
- else
- tor_free(sl->list[i]);
smartlist_del_keeporder(sl, i--);
}
}
@@ -530,7 +527,7 @@ smartlist_sort_strings(smartlist_t *sl)
void
smartlist_uniq_strings(smartlist_t *sl)
{
- smartlist_uniq(sl, _compare_string_ptrs, NULL);
+ smartlist_uniq(sl, _compare_string_ptrs, _tor_free);
}
/* Heap-based priority queue implementation for O(lg N) insert and remove.
@@ -653,7 +650,7 @@ smartlist_sort_digests(smartlist_t *sl)
void
smartlist_uniq_digests(smartlist_t *sl)
{
- smartlist_uniq(sl, _compare_digests, NULL);
+ smartlist_uniq(sl, _compare_digests, _tor_free);
}
#define DEFINE_MAP_STRUCTS(maptype, keydecl, prefix) \