summaryrefslogtreecommitdiffstats
path: root/apps/gui/option_select.c
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2009-08-20 16:47:44 +0000
committerNils Wallménius <nils@rockbox.org>2009-08-20 16:47:44 +0000
commit3200d04d75c5e7556ed8880b155533e881a4d1e1 (patch)
tree188e2c9525b25cb8922a14766e51ab02bad3f831 /apps/gui/option_select.c
parent0a1728444882cdbc6a0c815bd88464de25ad94e9 (diff)
downloadrockbox-3200d04d75c5e7556ed8880b155533e881a4d1e1.tar.gz
rockbox-3200d04d75c5e7556ed8880b155533e881a4d1e1.zip
Make the formatter functions used by the settings return a pointer to avoid usless copying of lang strings, this brought with it a long chain of const correctness and a few random cleanups
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22440 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/option_select.c')
-rw-r--r--apps/gui/option_select.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c
index 01259c4136..d806a0aa08 100644
--- a/apps/gui/option_select.c
+++ b/apps/gui/option_select.c
@@ -69,10 +69,11 @@ static const char *unit_strings[] =
/* these two vars are needed so arbitrary values can be added to the
TABLE_SETTING settings if the F_ALLOW_ARBITRARY_VALS flag is set */
static int table_setting_oldval = 0, table_setting_array_position = 0;
-char *option_get_valuestring(const struct settings_list *setting,
- char *buffer, int buf_len,
- intptr_t temp_var)
+const char *option_get_valuestring(const struct settings_list *setting,
+ char *buffer, int buf_len,
+ intptr_t temp_var)
{
+ const char* str = buffer;
if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING)
{
bool val = (bool)temp_var;
@@ -93,7 +94,7 @@ char *option_get_valuestring(const struct settings_list *setting,
const struct int_setting *int_info = setting->int_setting;
const struct table_setting *tbl_info = setting->table_setting;
const char *unit;
- void (*formatter)(char*, size_t, int, const char*);
+ const char* (*formatter)(char*, size_t, int, const char*);
if ((setting->flags & F_INT_SETTING) == F_INT_SETTING)
{
formatter = int_info->formatter;
@@ -105,7 +106,7 @@ char *option_get_valuestring(const struct settings_list *setting,
unit = unit_strings[tbl_info->unit];
}
if (formatter)
- formatter(buffer, buf_len, (int)temp_var, unit);
+ str = formatter(buffer, buf_len, (int)temp_var, unit);
else
snprintf(buffer, buf_len, "%d %s", (int)temp_var, unit?unit:"");
}
@@ -152,7 +153,7 @@ char *option_get_valuestring(const struct settings_list *setting,
strlcpy(buffer, val, buf_len);
}
}
- return buffer;
+ return str;
}
void option_talk_value(const struct settings_list *setting, int value, bool enqueue)
{
@@ -363,10 +364,11 @@ static int selection_to_val(const struct settings_list *setting, int selection)
}
return max- (selection * step);
}
-static char * value_setting_get_name_cb(int selected_item,
- void * data,
- char *buffer,
- size_t buffer_len)
+
+static const char * value_setting_get_name_cb(int selected_item,
+ void * data,
+ char *buffer,
+ size_t buffer_len)
{
selected_item = selection_to_val(data, selected_item);
return option_get_valuestring(data, buffer, buffer_len, selected_item);