#include "lib/malloc/util_malloc.h"
#include "lib/smartlist_core/smartlist_core.h"
-#define tor_assert raw_assert
-
#include <stdlib.h>
#include <string.h>
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;
}
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;
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;
}
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));
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 {
#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
const char *cp, *end, *next;
int n = 0;
- tor_assert(sl);
- tor_assert(str);
+ raw_assert(sl);
+ raw_assert(str);
cp = str;
while (1) {
;
}
- tor_assert(end);
+ raw_assert(end);
if (!*end) {
next = NULL;