summaryrefslogtreecommitdiffstats
path: root/help.c
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2011-12-03 11:13:10 -0800
committerDan Fandrich <dan@coneharvesters.com>2011-12-03 11:13:10 -0800
commit05df9d0879317816dcee00282eea3a06b0310c3b (patch)
treea454f493b83516bdcf750e881ab9803dd9f112fa /help.c
parent13e87955a6610317dd90b29b116edd5196cbcd56 (diff)
Declare many structures const (closes #3552)
Many structs used in mutt are actually constant but are defined without the 'const' keyword. This can slow initialization (slightly) in some environments due to extra copying and increases the amount of writable RAM required at run-time, which can be significant on non-MMU systems. Using const can also increase the opportunities for compiler optimization. The attached patch marks many such structures as const. On my test x86 build, this reduces the size of .data by over 50%.
Diffstat (limited to 'help.c')
-rw-r--r--help.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/help.c b/help.c
index 6d54059f..c1d2d0c6 100644
--- a/help.c
+++ b/help.c
@@ -31,10 +31,10 @@
#include <ctype.h>
#include <string.h>
-static struct binding_t *help_lookupFunction (int op, int menu)
+static const struct binding_t *help_lookupFunction (int op, int menu)
{
int i;
- struct binding_t *map;
+ const struct binding_t *map;
if (menu != MENU_PAGER)
{
@@ -66,7 +66,7 @@ void mutt_make_help (char *d, size_t dlen, char *txt, int menu, int op)
}
char *
-mutt_compile_help (char *buf, size_t buflen, int menu, struct mapping_t *items)
+mutt_compile_help (char *buf, size_t buflen, int menu, const struct mapping_t *items)
{
int i;
size_t len;
@@ -282,7 +282,7 @@ static void format_line (FILE *f, int ismacro,
static void dump_menu (FILE *f, int menu)
{
struct keymap_t *map;
- struct binding_t *b;
+ const struct binding_t *b;
char buf[SHORT_STRING];
/* browse through the keymap table */
@@ -318,7 +318,7 @@ static int is_bound (struct keymap_t *map, int op)
}
static void dump_unbound (FILE *f,
- struct binding_t *funcs,
+ const struct binding_t *funcs,
struct keymap_t *map,
struct keymap_t *aux)
{
@@ -336,9 +336,9 @@ void mutt_help (int menu)
{
char t[_POSIX_PATH_MAX];
char buf[SHORT_STRING];
- char *desc;
+ const char *desc;
FILE *f;
- struct binding_t *funcs;
+ const struct binding_t *funcs;
mutt_mktemp (t, sizeof (t));