aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/vty
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-04-30 12:26:52 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-04-30 13:29:34 +0800
commit1700c933f202260345caf733c5d147a1243aef48 (patch)
tree1652ab11115fb0c4b62e26adc47beac7fbb50c57 /openbsc/src/vty
parent9e282de7c8c856975aa41ab100e38f1891962936 (diff)
[vty] Allow to create a buffer in a given context.
Stop using the global vty context for all allocations and allow to embed the buffer into a given context, and allocate sub buffers with the context of its parent.
Diffstat (limited to 'openbsc/src/vty')
-rw-r--r--openbsc/src/vty/buffer.c6
-rw-r--r--openbsc/src/vty/vty.c2
2 files changed, 4 insertions, 4 deletions
diff --git a/openbsc/src/vty/buffer.c b/openbsc/src/vty/buffer.c
index 195d06209..0bc1760cc 100644
--- a/openbsc/src/vty/buffer.c
+++ b/openbsc/src/vty/buffer.c
@@ -65,11 +65,11 @@ struct buffer_data {
#define BUFFER_DATA_FREE(D) talloc_free((D))
/* Make new buffer. */
-struct buffer *buffer_new(size_t size)
+struct buffer *buffer_new(void *ctx, size_t size)
{
struct buffer *b;
- b = talloc_zero(tall_vty_ctx, struct buffer);
+ b = talloc_zero(ctx, struct buffer);
if (size)
b->size = size;
@@ -138,7 +138,7 @@ static struct buffer_data *buffer_add(struct buffer *b)
{
struct buffer_data *d;
- d = _talloc_zero(tall_vty_ctx,
+ d = _talloc_zero(b,
offsetof(struct buffer_data, data[b->size]),
"buffer_add");
if (!d)
diff --git a/openbsc/src/vty/vty.c b/openbsc/src/vty/vty.c
index 8455b0e3d..5e4902441 100644
--- a/openbsc/src/vty/vty.c
+++ b/openbsc/src/vty/vty.c
@@ -51,7 +51,7 @@ struct vty *vty_new()
if (!new)
goto out;
- new->obuf = buffer_new(0); /* Use default buffer size. */
+ new->obuf = buffer_new(new, 0); /* Use default buffer size. */
if (!new->obuf)
goto out_new;
new->buf = _talloc_zero(new, VTY_BUFSIZ, "vty_new->buf");