summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2024-12-08 03:11:11 -0500
committerWilliam Wilgus <wilgus.william@gmail.com>2024-12-08 03:52:38 -0500
commit33cbefb310b8a195047edb502921467ac1e5386e (patch)
tree92b0445cbacb4f7b134095cd969264eb1506a799
parentebd1021fe4730f41c13efb8f96a0e027f9e5f62f (diff)
downloadrockbox-33cbefb310.tar.gz
rockbox-33cbefb310.zip
skin_parser Reduce ram usage for conditionals on %ft() file text tags
the skin engine calls the tags for each conditional to check them since %ft erases it's var if the file doesn't exist %?ft is likely only being called to check existance of a file or line of a file this patch allocates 2 bytes to satisify the conditional if the line exists Change-Id: Ic74bf5fec9a5d9b6724692c49a0997bfa4cff48d
-rw-r--r--apps/gui/skin_engine/skin_parser.c6
-rw-r--r--lib/skin_parser/skin_parser.c2
-rw-r--r--lib/skin_parser/skin_parser.h1
3 files changed, 9 insertions, 0 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index c9931d5b29..d60aa11249 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -1380,7 +1380,13 @@ static int parse_filetext(struct skin_element *element,
goto failure;
}
+ if (element->is_conditional)
+ {
+ rd = 1; /* just alloc enough for the conditional to work*/
+ }
+
buf[rd] = '\0';
+
char * skinbuf = skin_buffer_alloc(rd+1);
if (!skinbuf)
diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c
index 4afde7bc67..4a1a168d70 100644
--- a/lib/skin_parser/skin_parser.c
+++ b/lib/skin_parser/skin_parser.c
@@ -932,6 +932,7 @@ static int skin_parse_conditional(struct skin_element* element, const char** doc
* value */
element->type = TAG;
element->line = skin_line;
+ element->is_conditional = true;
/* Parsing the tag first */
if(!skin_parse_tag(element, &cursor))
@@ -1152,6 +1153,7 @@ static struct skin_element* skin_alloc_element()
retval->params_count = 0;
retval->children_count = 0;
retval->data = INVALID_OFFSET;
+ retval->is_conditional = false;
return retval;
diff --git a/lib/skin_parser/skin_parser.h b/lib/skin_parser/skin_parser.h
index cb2bdaf002..f6ba2a2239 100644
--- a/lib/skin_parser/skin_parser.h
+++ b/lib/skin_parser/skin_parser.h
@@ -146,6 +146,7 @@ struct skin_element
enum skin_element_type type;
/* Number of elements in the params array */
char params_count;
+ bool is_conditional;
};
enum skin_cb_returnvalue