summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--boot/scene.c8
-rw-r--r--include/expo.h10
-rw-r--r--test/boot/expo.c19
3 files changed, 17 insertions, 20 deletions
diff --git a/boot/scene.c b/boot/scene.c
index 030f6aa2a0a..d2f77c008cf 100644
--- a/boot/scene.c
+++ b/boot/scene.c
@@ -65,16 +65,12 @@ void scene_destroy(struct scene *scn)
scene_obj_destroy(obj);
free(scn->name);
- free(scn->title);
free(scn);
}
-int scene_title_set(struct scene *scn, const char *title)
+int scene_title_set(struct scene *scn, uint id)
{
- free(scn->title);
- scn->title = strdup(title);
- if (!scn->title)
- return log_msg_ret("tit", -ENOMEM);
+ scn->title_id = id;
return 0;
}
diff --git a/include/expo.h b/include/expo.h
index d242f48e30c..8827f4b0b45 100644
--- a/include/expo.h
+++ b/include/expo.h
@@ -92,7 +92,7 @@ struct expo_string {
* @expo: Expo this scene is part of
* @name: Name of the scene (allocated)
* @id: ID number of the scene
- * @title: Title of the scene (allocated)
+ * @title_id: String ID of title of the scene (allocated)
* @sibling: Node to link this scene to its siblings
* @obj_head: List of objects in the scene
*/
@@ -100,7 +100,7 @@ struct scene {
struct expo *expo;
char *name;
uint id;
- char *title;
+ uint title_id;
struct list_head sibling;
struct list_head obj_head;
};
@@ -338,10 +338,10 @@ struct scene *expo_lookup_scene_id(struct expo *exp, uint scene_id);
* scene_title_set() - set the scene title
*
* @scn: Scene to update
- * @title: Title to set, NULL if none (this is allocated by this call)
- * Returns: 0 if OK, -ENOMEM if out of memory
+ * @title_id: Title ID to set
+ * Returns: 0 if OK
*/
-int scene_title_set(struct scene *scn, const char *title);
+int scene_title_set(struct scene *scn, uint title_id);
/**
* scene_obj_count() - Count the number of objects in a scene
diff --git a/test/boot/expo.c b/test/boot/expo.c
index 7104dff05e8..3c0bc78bb7a 100644
--- a/test/boot/expo.c
+++ b/test/boot/expo.c
@@ -28,6 +28,8 @@ enum {
OBJ_MENU_TITLE,
/* strings */
+ STR_SCENE_TITLE,
+
STR_TEXT,
STR_TEXT2,
STR_MENU_TITLE,
@@ -120,7 +122,7 @@ static int expo_scene(struct unit_test_state *uts)
struct expo *exp;
ulong start_mem;
char name[100];
- int id;
+ int id, title_id;
start_mem = ut_check_free();
@@ -141,21 +143,20 @@ static int expo_scene(struct unit_test_state *uts)
ut_asserteq_str(SCENE_NAME1, scn->name);
/* Set the title */
- strcpy(name, SCENE_TITLE);
- ut_assertok(scene_title_set(scn, name));
- *name = '\0';
- ut_assertnonnull(scn->title);
- ut_asserteq_str(SCENE_TITLE, scn->title);
+ title_id = expo_str(exp, "title", STR_SCENE_TITLE, SCENE_TITLE);
+ ut_assert(title_id >= 0);
- /* Use an allocated ID */
+ /* Use an allocated ID - this will be allocated after the title str */
scn = NULL;
id = scene_new(exp, SCENE_NAME2, 0, &scn);
ut_assertnonnull(scn);
- ut_asserteq(SCENE2, id);
- ut_asserteq(SCENE2 + 1, exp->next_id);
+ ut_assertok(scene_title_set(scn, title_id));
+ ut_asserteq(STR_SCENE_TITLE + 1, id);
+ ut_asserteq(STR_SCENE_TITLE + 2, exp->next_id);
ut_asserteq_ptr(exp, scn->expo);
ut_asserteq_str(SCENE_NAME2, scn->name);
+ ut_asserteq(title_id, scn->title_id);
expo_destroy(exp);