From 97b586695cd80821455ae06ee178c6c8cf759ce6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 1 May 2025 07:37:01 -0600 Subject: abuf: Add a helper for initing and allocating a buffer This construct appears in various places. Reduce code size by adding a function for it. It inits the abuf, then allocates it to the requested size. Signed-off-by: Simon Glass --- include/abuf.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/abuf.h b/include/abuf.h index 62ff6499a0c..749bb188b0c 100644 --- a/include/abuf.h +++ b/include/abuf.h @@ -170,6 +170,17 @@ void abuf_init_set(struct abuf *abuf, void *data, size_t size); */ void abuf_init_const(struct abuf *abuf, const void *data, size_t size); +/** + * abuf_init_size() - Set up an allocated abuf + * + * Init a new abuf and allocate its size. + * + * @abuf: abuf to set up + * @data: New contents of abuf + * @size: New size of abuf + */ +bool abuf_init_size(struct abuf *buf, size_t size); + /** * abuf_uninit() - Free any memory used by an abuf * -- cgit v1.2.3