aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/container.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/common/container.c b/src/common/container.c
index 42651b83d9..4c8703ca32 100644
--- a/src/common/container.c
+++ b/src/common/container.c
@@ -109,7 +109,16 @@ smartlist_add(smartlist_t *sl, void *element) {
void
smartlist_add_all(smartlist_t *sl, const smartlist_t *s2)
{
- SMARTLIST_FOREACH(s2, void *, element, smartlist_add(sl, element));
+ int n2 = sl->num_used + s2->num_used;
+ if (n2 > sl->capacity) {
+ int higher = sl->capacity * 2;
+ while (n2 > higher)
+ higher *= 2;
+ sl->capacity = higher;
+ sl->list = tor_realloc(sl->list, sizeof(void*)*sl->capacity);
+ }
+ memcpy(sl->list + sl->num_used, s2->list, s2->num_used*sizeof(void*));
+ sl->num_used += s2->num_used;
}
/** Remove all elements E from sl such that E==element. Preserve