1
0
mirror of https://gitlab.labs.nic.cz/labs/bird.git synced 2024-05-11 16:54:54 +00:00

Printf variant with a result allocated inside a pool / linpool

This commit is contained in:
Maria Matejka
2022-03-15 11:21:46 +01:00
parent 3c42f7af6a
commit c53f547a0b
5 changed files with 69 additions and 22 deletions

View File

@@ -70,6 +70,20 @@ rp_new(pool *p, const char *name)
return z;
}
pool *
rp_newf(pool *p, const char *fmt, ...)
{
pool *z = rp_new(p, NULL);
va_list args;
va_start(args, fmt);
z->name = mb_vsprintf(p, fmt, args);
va_end(args);
return z;
}
static void
pool_free(resource *P)
{
@@ -410,21 +424,6 @@ mb_realloc(void *m, unsigned size)
return b->data;
}
/**
* mb_move - move a memory block
* @m: memory block
* @p: target pool
*
* mb_move() moves the given memory block to another pool in the same way
* as rmove() moves a plain resource.
*/
void
mb_move(void *m, pool *p)
{
struct mblock *b = SKIP_BACK(struct mblock, data, m);
rmove(b, p);
}
/**
* mb_free - free a memory block