vty: sub-divide talloc contexts and include them in talloc report
The VTY code makes so many allocations that a full report is
simply too long to provide any useful information. So we sub-divide
it in multiple contexts, and report only one level deep at SIGURS1.
We also introduce SIGUSR2 for the full detailed VTY report.
diff --git a/openbsc/src/vty/vector.c b/openbsc/src/vty/vector.c
index 371f71d..06e1aaa 100644
--- a/openbsc/src/vty/vector.c
+++ b/openbsc/src/vty/vector.c
@@ -27,10 +27,12 @@
#include <openbsc/talloc.h>
#include <memory.h>
+void *tall_vty_vec_ctx;
+
/* Initialize vector : allocate memory and return vector. */
vector vector_init(unsigned int size)
{
- vector v = talloc_zero(tall_vty_ctx, struct _vector);
+ vector v = talloc_zero(tall_vty_vec_ctx, struct _vector);
if (!v)
return NULL;
@@ -40,7 +42,7 @@
v->alloced = size;
v->active = 0;
- v->index = _talloc_zero(tall_vty_ctx, sizeof(void *) * size,
+ v->index = _talloc_zero(tall_vty_vec_ctx, sizeof(void *) * size,
"vector_init:index");
if (!v->index) {
talloc_free(v);
@@ -68,7 +70,7 @@
vector vector_copy(vector v)
{
unsigned int size;
- vector new = talloc_zero(tall_vty_ctx, struct _vector);
+ vector new = talloc_zero(tall_vty_vec_ctx, struct _vector);
if (!new)
return NULL;
@@ -76,7 +78,7 @@
new->alloced = v->alloced;
size = sizeof(void *) * (v->alloced);
- new->index = _talloc_zero(tall_vty_ctx, size, "vector_copy:index");
+ new->index = _talloc_zero(tall_vty_vec_ctx, size, "vector_copy:index");
if (!new->index) {
talloc_free(new);
return NULL;
@@ -92,7 +94,7 @@
if (v->alloced > num)
return;
- v->index = talloc_realloc_size(tall_vty_ctx, v->index,
+ v->index = talloc_realloc_size(tall_vty_vec_ctx, v->index,
sizeof(void *) * (v->alloced * 2));
memset(&v->index[v->alloced], 0, sizeof(void *) * v->alloced);
v->alloced *= 2;