From 3d15dcdb1cc91c694aa9319b86bb37510d7ed12b Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Wed, 10 Jun 2009 23:45:08 +0200 Subject: Changes OSPF to generate stub networks for non-primary addresses. Also does some reorganization in RT LSA announcement. --- lib/resource.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'lib/resource.c') diff --git a/lib/resource.c b/lib/resource.c index 9e62681..289af93 100644 --- a/lib/resource.c +++ b/lib/resource.c @@ -327,6 +327,42 @@ mb_allocz(pool *p, unsigned size) return x; } +/** + * mb_realloc - reallocate a memory block + * @p: pool + * @m: memory block + * @size: new size of the block + * + * mb_realloc() changes the size of the memory block @m to a given size. + * The contents will be unchanged to the minimum of the old and new sizes; + * newly allocated memory will be uninitialized. If @m is NULL, the call + * is equivalent to mb_alloc(@p, @size). + * + * Like mb_alloc(), mb_realloc() also returns a pointer to the memory + * chunk , not to the resource, hence you have to free it using + * mb_free(), not rfree(). + */ +void * +mb_realloc(pool *p, void *m, unsigned size) +{ + struct mblock *ob = NULL; + + if (m) + { + ob = SKIP_BACK(struct mblock, data, m); + if (ob->r.n.next) + rem_node(&ob->r.n); + } + + struct mblock *b = xrealloc(ob, sizeof(struct mblock) + size); + + b->r.class = &mb_class; + add_tail(&p->inside, &b->r.n); + b->size = size; + return b->data; +} + + /** * mb_free - free a memory block * @m: memory block @@ -339,3 +375,4 @@ mb_free(void *m) struct mblock *b = SKIP_BACK(struct mblock, data, m); rfree(b); } + -- cgit v1.2.3