diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-05-28 10:59:35 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-05-28 10:59:35 -0400 |
commit | d3125a3e404f4967d9100d793b01dcbed6eeadc2 (patch) | |
tree | 9f2de5bded17af897b58e99f86e59d44e47e17d6 /src/common | |
parent | e7134c2375f3c577ab7dcc20c74c5773d1a5f37d (diff) | |
parent | 3795f6a78b84ffcbe9bf464d5e569ae3c718d03e (diff) | |
download | tor-d3125a3e404f4967d9100d793b01dcbed6eeadc2.tar tor-d3125a3e404f4967d9100d793b01dcbed6eeadc2.tar.gz |
Merge remote-tracking branch 'karsten/task-6752-3'
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/container.c | 19 | ||||
-rw-r--r-- | src/common/container.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/common/container.c b/src/common/container.c index eec497a3e..476dc8291 100644 --- a/src/common/container.c +++ b/src/common/container.c @@ -243,6 +243,25 @@ smartlist_strings_eq(const smartlist_t *sl1, const smartlist_t *sl2) return 1; } +/** Return true iff the two lists contain the same int pointer values in + * the same order, or if they are both NULL. */ +int +smartlist_ints_eq(const smartlist_t *sl1, const smartlist_t *sl2) +{ + if (sl1 == NULL) + return sl2 == NULL; + if (sl2 == NULL) + return 0; + if (smartlist_len(sl1) != smartlist_len(sl2)) + return 0; + SMARTLIST_FOREACH(sl1, int *, cp1, { + int *cp2 = smartlist_get(sl2, cp1_sl_idx); + if (*cp1 != *cp2) + return 0; + }); + return 1; +} + /** Return true iff <b>sl</b> has some element E such that * tor_memeq(E,<b>element</b>,DIGEST_LEN) */ diff --git a/src/common/container.h b/src/common/container.h index 1a68b8f67..1bcc54066 100644 --- a/src/common/container.h +++ b/src/common/container.h @@ -42,6 +42,7 @@ int smartlist_contains_string_case(const smartlist_t *sl, const char *element); int smartlist_contains_int_as_string(const smartlist_t *sl, int num); int smartlist_strings_eq(const smartlist_t *sl1, const smartlist_t *sl2); int smartlist_contains_digest(const smartlist_t *sl, const char *element); +int smartlist_ints_eq(const smartlist_t *sl1, const smartlist_t *sl2); int smartlist_overlap(const smartlist_t *sl1, const smartlist_t *sl2); void smartlist_intersect(smartlist_t *sl1, const smartlist_t *sl2); void smartlist_subtract(smartlist_t *sl1, const smartlist_t *sl2); |