]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
expo: Use an abuf to hold strings
authorSimon Glass <sjg@chromium.org>
Fri, 2 May 2025 14:46:32 +0000 (08:46 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 30 May 2025 08:49:32 +0000 (09:49 +0100)
It is more convenient to put strings in an abuf so they can easily be
resized. Adjust the struct accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
boot/expo.c
include/expo.h

index 301bbfa5f9afabdd7cf28095cce0466f9ce48494..debdb60022b9ac9c0df0630c489bb83445bb9017 100644 (file)
@@ -86,7 +86,7 @@ int expo_str(struct expo *exp, const char *name, uint id, const char *str)
                return log_msg_ret("obj", -ENOMEM);
 
        estr->id = resolve_id(exp, id);
-       estr->str = str;
+       abuf_init_const(&estr->buf, str, strlen(str) + 1);
        list_add_tail(&estr->sibling, &exp->str_head);
 
        return estr->id;
@@ -98,7 +98,7 @@ const char *expo_get_str(struct expo *exp, uint id)
 
        list_for_each_entry(estr, &exp->str_head, sibling) {
                if (estr->id == id)
-                       return estr->str;
+                       return estr->buf.data;
        }
 
        return NULL;
index 84dc77f771ee1957675a0e904d1a27bb10720a3e..b6de0310071d3e2c70c5271e7448e4bac9744b2c 100644 (file)
@@ -134,12 +134,12 @@ struct expo {
  * struct expo_string - a string that can be used in an expo
  *
  * @id: ID number of the string
- * @str: String
+ * @buf: String (contains nul terminator)
  * @sibling: Node to link this object to its siblings
  */
 struct expo_string {
        uint id;
-       const char *str;
+       struct abuf buf;
        struct list_head sibling;
 };