diff options
author | Harald Welte <laforge@netfilter.org> | 2009-08-07 13:25:41 +0200 |
---|---|---|
committer | Harald Welte <laforge@netfilter.org> | 2009-08-07 13:25:41 +0200 |
commit | 0224e4d051ad7bd159ae82512bc554e90f4de99f (patch) | |
tree | 494abf11b26bb70b6911b3c0e7a91115d2b9bfb7 /openbsc/src/vty/vector.c | |
parent | 2477d93c6e2fbda33e423f5514d591ea64da1685 (diff) |
use one talloc context for entire vty code
Diffstat (limited to 'openbsc/src/vty/vector.c')
-rw-r--r-- | openbsc/src/vty/vector.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/openbsc/src/vty/vector.c b/openbsc/src/vty/vector.c index c8885a414..371f71d95 100644 --- a/openbsc/src/vty/vector.c +++ b/openbsc/src/vty/vector.c @@ -23,15 +23,14 @@ #include <unistd.h> #include <vty/vector.h> +#include <vty/vty.h> #include <openbsc/talloc.h> #include <memory.h> -static void *tall_vvec_ctx; - /* Initialize vector : allocate memory and return vector. */ vector vector_init(unsigned int size) { - vector v = talloc_zero(tall_vvec_ctx, struct _vector); + vector v = talloc_zero(tall_vty_ctx, struct _vector); if (!v) return NULL; @@ -41,7 +40,7 @@ vector vector_init(unsigned int size) v->alloced = size; v->active = 0; - v->index = _talloc_zero(tall_vvec_ctx, sizeof(void *) * size, + v->index = _talloc_zero(tall_vty_ctx, sizeof(void *) * size, "vector_init:index"); if (!v->index) { talloc_free(v); @@ -69,7 +68,7 @@ void vector_free(vector v) vector vector_copy(vector v) { unsigned int size; - vector new = talloc_zero(tall_vvec_ctx, struct _vector); + vector new = talloc_zero(tall_vty_ctx, struct _vector); if (!new) return NULL; @@ -77,7 +76,7 @@ vector vector_copy(vector v) new->alloced = v->alloced; size = sizeof(void *) * (v->alloced); - new->index = _talloc_zero(tall_vvec_ctx, size, "vector_copy:index"); + new->index = _talloc_zero(tall_vty_ctx, size, "vector_copy:index"); if (!new->index) { talloc_free(new); return NULL; @@ -93,7 +92,7 @@ void vector_ensure(vector v, unsigned int num) if (v->alloced > num) return; - v->index = talloc_realloc_size(tall_vvec_ctx, v->index, + v->index = talloc_realloc_size(tall_vty_ctx, v->index, sizeof(void *) * (v->alloced * 2)); memset(&v->index[v->alloced], 0, sizeof(void *) * v->alloced); v->alloced *= 2; @@ -189,8 +188,3 @@ unsigned int vector_count(vector v) return count; } - -static __attribute__((constructor)) void on_dso_load_vty_vec(void) -{ - tall_vvec_ctx = talloc_named_const(NULL, 1, "vty_vector"); -} |