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 <sjg@chromium.org>
diff --git a/boot/scene.c b/boot/scene.c
index fb82ffe..90b4ccf 100644
--- a/boot/scene.c
+++ b/boot/scene.c
@@ -31,8 +31,7 @@
return log_msg_ret("name", -ENOMEM);
}
- abuf_init(&scn->buf);
- if (!abuf_realloc(&scn->buf, EXPO_MAX_CHARS + 1)) {
+ if (!abuf_init_size(&scn->buf, EXPO_MAX_CHARS + 1)) {
free(scn->name);
free(scn);
return log_msg_ret("buf", -ENOMEM);