From: Maria Matejka Date: Tue, 30 Mar 2021 14:03:33 +0000 (+0200) Subject: Resources: added mb_move() to complement rmove() for memory blocks X-Git-Tag: v2.0.9~90 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a9938b179203a4d5c54eae6c814bfa8766f4fde0;p=thirdparty%2Fbird.git Resources: added mb_move() to complement rmove() for memory blocks --- diff --git a/lib/resource.c b/lib/resource.c index 5589373e0..4c4b92ecd 100644 --- a/lib/resource.c +++ b/lib/resource.c @@ -393,6 +393,21 @@ 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 diff --git a/lib/resource.h b/lib/resource.h index 48e629852..e65455c8e 100644 --- a/lib/resource.h +++ b/lib/resource.h @@ -53,6 +53,7 @@ extern pool root_pool; void *mb_alloc(pool *, unsigned size); void *mb_allocz(pool *, unsigned size); void *mb_realloc(void *m, unsigned size); +void mb_move(void *, pool *); void mb_free(void *); /* Memory pools with linear allocation */