From 3200d04d75c5e7556ed8880b155533e881a4d1e1 Mon Sep 17 00:00:00 2001 From: Nils Wallménius Date: Thu, 20 Aug 2009 16:47:44 +0000 Subject: 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 --- apps/plugins/goban/goban.c | 20 +++++++++++--------- apps/plugins/goban/types.h | 2 +- apps/plugins/goban/util.c | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) (limited to 'apps/plugins/goban') diff --git a/apps/plugins/goban/goban.c b/apps/plugins/goban/goban.c index 65a03f6953..4e20e71a37 100644 --- a/apps/plugins/goban/goban.c +++ b/apps/plugins/goban/goban.c @@ -114,37 +114,39 @@ set_defaults (void) autosave_time = 7; } -static void +static const char* komi_formatter (char *dest, size_t size, int menu_item, const char *unknown) { (void) unknown; snprint_fixed (dest, size, menu_item); + return dest; } -static void +static const char* ruleset_formatter (char *dest, size_t size, int menu_item, const char *unknown) { - (void) unknown; - rb->snprintf (dest, size, "%s", ruleset_names[menu_item]); + (void)dest, (void)size, (void)unknown; + return ruleset_names[menu_item]; } -static void +static const char* autosave_formatter (char *dest, size_t size, int menu_item, const char * unknown) { (void) unknown; if (menu_item == 0) { - rb->snprintf (dest, size, "Off"); + return "Off"; } else { rb->snprintf (dest, size, "%d minute%s", menu_item, menu_item == 1 ? "" : "s"); + return dest; } } -static void +static const char* time_formatter (char *dest, size_t size, int menu_item, const char *unknown) { int time_values[4]; /* days hours minutes seconds */ @@ -183,8 +185,7 @@ time_formatter (char *dest, size_t size, int menu_item, const char *unknown) if (max_set == -1) { - rb->snprintf (dest, size, "0"); - return; + return "0"; } for (i = min_set; i <= 3; ++i) @@ -236,6 +237,7 @@ time_formatter (char *dest, size_t size, int menu_item, const char *unknown) dest += temp; size -= temp; } + return dest; } enum plugin_status diff --git a/apps/plugins/goban/types.h b/apps/plugins/goban/types.h index 216d41bc21..a7c2b9b0ae 100644 --- a/apps/plugins/goban/types.h +++ b/apps/plugins/goban/types.h @@ -218,7 +218,7 @@ struct prop_t /* The names of the rulesets, ex. "AGA", "Japanese", etc. */ -extern char *ruleset_names[]; +extern const char *ruleset_names[]; /* IMPORTANT! keep in sync with ruleset_names!!! */ enum ruleset_t diff --git a/apps/plugins/goban/util.c b/apps/plugins/goban/util.c index e9966311ef..0e83173f40 100644 --- a/apps/plugins/goban/util.c +++ b/apps/plugins/goban/util.c @@ -210,7 +210,7 @@ char *prop_names[] = { /* These seems to be specified by the SGF specification. You can do free form ones as well, but I haven't implemented that (and don't plan to) */ -char *ruleset_names[] = { "AGA", "Japanese", "Chinese", "NZ", "GOE" }; +const char *ruleset_names[] = { "AGA", "Japanese", "Chinese", "NZ", "GOE" }; -- cgit v1.2.3