summaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authorSimon Glass <[email protected]>2025-05-01 07:37:01 -0600
committerSimon Glass <[email protected]>2025-05-30 09:49:31 +0100
commit97b586695cd80821455ae06ee178c6c8cf759ce6 (patch)
tree51e652168f67b87cfc9fd044079d83a2b574ba7f /boot
parenta619c4410956f446510749b6dc3989849616b7a0 (diff)
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 <[email protected]>
Diffstat (limited to 'boot')
-rw-r--r--boot/cedit.c3
-rw-r--r--boot/scene.c3
-rw-r--r--boot/scene_textline.c3
3 files changed, 3 insertions, 6 deletions
diff --git a/boot/cedit.c b/boot/cedit.c
index d69290c172e..4e80875828b 100644
--- a/boot/cedit.c
+++ b/boot/cedit.c
@@ -449,8 +449,7 @@ int cedit_write_settings(struct expo *exp, struct abuf *buf)
void *fdt;
int ret;
- abuf_init(buf);
- if (!abuf_realloc(buf, CEDIT_SIZE_INC))
+ if (!abuf_init_size(buf, CEDIT_SIZE_INC))
return log_msg_ret("buf", -ENOMEM);
fdt = abuf_data(buf);
diff --git a/boot/scene.c b/boot/scene.c
index fb82ffe768c..90b4ccf4766 100644
--- a/boot/scene.c
+++ b/boot/scene.c
@@ -31,8 +31,7 @@ int scene_new(struct expo *exp, const char *name, uint id, struct scene **scnp)
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);
diff --git a/boot/scene_textline.c b/boot/scene_textline.c
index 6adef7cc173..90642a3f03d 100644
--- a/boot/scene_textline.c
+++ b/boot/scene_textline.c
@@ -31,8 +31,7 @@ int scene_textline(struct scene *scn, const char *name, uint id, uint max_chars,
(struct scene_obj **)&tline);
if (ret < 0)
return log_msg_ret("obj", -ENOMEM);
- abuf_init(&tline->buf);
- if (!abuf_realloc(&tline->buf, max_chars + 1))
+ if (!abuf_init_size(&tline->buf, max_chars + 1))
return log_msg_ret("buf", -ENOMEM);
buf = abuf_data(&tline->buf);
*buf = '\0';