From 2689cb081b4011fea08947e2f7a8f74cd61a1903 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 12 Sep 2005 08:27:01 +0000 Subject: We have so many special cases for smartlists of strings, why not add a sort function? svn:r5014 --- src/common/container.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/common/container.c') diff --git a/src/common/container.c b/src/common/container.c index 766e6deb9c..1e6d1954d2 100644 --- a/src/common/container.c +++ b/src/common/container.c @@ -419,6 +419,18 @@ smartlist_bsearch(smartlist_t *sl, const void *key, return r ? *r : NULL; } +static int +_compare_string_ptrs(void **_a, void **_b) +{ + return strcmp((char*)*_a, (char*)*_b); +} + +void +smartlist_sort_strings(smartlist_t *sl) +{ + smartlist_sort(sl, _compare_string_ptrs); +} + /* Splay-tree implementation of string-to-void* map */ typedef struct strmap_entry_t { -- cgit v1.2.3-54-g00ecf