diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-06-26 12:16:04 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-06-26 12:16:04 -0400 |
commit | d7bd8cf3b6d70f3014bb1140d0d018f94fedb178 (patch) | |
tree | c8d092b7b4dd12f6a39f16ed89c5d0d8fee45fe6 /src/lib/smartlist_core | |
parent | b1de1e7a77275ad3e8a65d984ff1e9779920e933 (diff) | |
download | tor-d7bd8cf3b6d70f3014bb1140d0d018f94fedb178.tar.gz tor-d7bd8cf3b6d70f3014bb1140d0d018f94fedb178.zip |
Use raw_assert directly in smartlist_core
I had previously added a "#define tor_assert raw_assert" here, to
make code movement in the previous commit more clear.
Diffstat (limited to 'src/lib/smartlist_core')
-rw-r--r-- | src/lib/smartlist_core/smartlist_core.c | 26 | ||||
-rw-r--r-- | src/lib/smartlist_core/smartlist_split.c | 8 |
2 files changed, 15 insertions, 19 deletions
diff --git a/src/lib/smartlist_core/smartlist_core.c b/src/lib/smartlist_core/smartlist_core.c index ca5c5f0bf1..aefdd77099 100644 --- a/src/lib/smartlist_core/smartlist_core.c +++ b/src/lib/smartlist_core/smartlist_core.c @@ -14,8 +14,6 @@ #include "lib/malloc/util_malloc.h" #include "lib/smartlist_core/smartlist_core.h" -#define tor_assert raw_assert - #include <stdlib.h> #include <string.h> @@ -103,10 +101,10 @@ void smartlist_add_all(smartlist_t *s1, const smartlist_t *s2) { size_t new_size = (size_t)s1->num_used + (size_t)s2->num_used; - tor_assert(new_size >= (size_t) s1->num_used); /* check for overflow. */ + raw_assert(new_size >= (size_t) s1->num_used); /* check for overflow. */ smartlist_ensure_capacity(s1, new_size); memcpy(s1->list + s1->num_used, s2->list, s2->num_used*sizeof(void*)); - tor_assert(new_size <= INT_MAX); /* redundant. */ + raw_assert(new_size <= INT_MAX); /* redundant. */ s1->num_used = (int) new_size; } @@ -162,7 +160,7 @@ smartlist_remove_keeporder(smartlist_t *sl, const void *element) void * smartlist_pop_last(smartlist_t *sl) { - tor_assert(sl); + raw_assert(sl); if (sl->num_used) { void *tmp = sl->list[--sl->num_used]; sl->list[sl->num_used] = NULL; @@ -190,9 +188,9 @@ smartlist_contains(const smartlist_t *sl, const void *element) void smartlist_del(smartlist_t *sl, int idx) { - tor_assert(sl); - tor_assert(idx>=0); - tor_assert(idx < sl->num_used); + raw_assert(sl); + raw_assert(idx>=0); + raw_assert(idx < sl->num_used); sl->list[idx] = sl->list[--sl->num_used]; sl->list[sl->num_used] = NULL; } @@ -204,9 +202,9 @@ smartlist_del(smartlist_t *sl, int idx) void smartlist_del_keeporder(smartlist_t *sl, int idx) { - tor_assert(sl); - tor_assert(idx>=0); - tor_assert(idx < sl->num_used); + raw_assert(sl); + raw_assert(idx>=0); + raw_assert(idx < sl->num_used); --sl->num_used; if (idx < sl->num_used) memmove(sl->list+idx, sl->list+idx+1, sizeof(void*)*(sl->num_used-idx)); @@ -220,9 +218,9 @@ smartlist_del_keeporder(smartlist_t *sl, int idx) void smartlist_insert(smartlist_t *sl, int idx, void *val) { - tor_assert(sl); - tor_assert(idx>=0); - tor_assert(idx <= sl->num_used); + raw_assert(sl); + raw_assert(idx>=0); + raw_assert(idx <= sl->num_used); if (idx == sl->num_used) { smartlist_add(sl, val); } else { diff --git a/src/lib/smartlist_core/smartlist_split.c b/src/lib/smartlist_core/smartlist_split.c index e24a742c21..b9340e7924 100644 --- a/src/lib/smartlist_core/smartlist_split.c +++ b/src/lib/smartlist_core/smartlist_split.c @@ -13,8 +13,6 @@ #include <string.h> -#define tor_assert raw_assert - /** * Split a string <b>str</b> along all occurrences of <b>sep</b>, * appending the (newly allocated) split strings, in order, to @@ -37,8 +35,8 @@ smartlist_split_string(smartlist_t *sl, const char *str, const char *sep, const char *cp, *end, *next; int n = 0; - tor_assert(sl); - tor_assert(str); + raw_assert(sl); + raw_assert(str); cp = str; while (1) { @@ -57,7 +55,7 @@ smartlist_split_string(smartlist_t *sl, const char *str, const char *sep, ; } - tor_assert(end); + raw_assert(end); if (!*end) { next = NULL; |