diff options
author | Uli Schlachter <psychon@znc.in> | 2015-03-18 22:11:48 +0100 |
---|---|---|
committer | Uli Schlachter <psychon@znc.in> | 2015-03-18 22:11:48 +0100 |
commit | 925ab1e7fb6ba1b243ffa77912442bfa82416d04 (patch) | |
tree | 80a27afe07fc947f8d489416388c45dcb16304db /src | |
parent | 514070caf83ac09478383990d8b3f91493dc1a35 (diff) |
Define the "unknown foo" lists as strings
This gets rid of lots of relocations that were needed for the pointers into the
strings.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Diffstat (limited to 'src')
-rw-r--r-- | src/errors.h | 6 | ||||
-rw-r--r-- | src/static_tables.c | 12 | ||||
-rw-r--r-- | src/xcb_errors.c | 6 |
3 files changed, 12 insertions, 12 deletions
diff --git a/src/errors.h b/src/errors.h index c48cf81..993575c 100644 --- a/src/errors.h +++ b/src/errors.h @@ -35,9 +35,9 @@ struct static_extension_info_t { const char *strings_errors; }; -extern const char *unknown_major_code[256]; -extern const char *unknown_error_code[256]; -extern const char *unknown_event_code[256]; +extern const char unknown_major_code[]; +extern const char unknown_error_code[]; +extern const char unknown_event_code[]; const char *xproto_get_name_for_major_code(uint8_t major_code); const char *xproto_get_name_for_event(uint8_t event_code); diff --git a/src/static_tables.c b/src/static_tables.c index 67c9481..187acf8 100644 --- a/src/static_tables.c +++ b/src/static_tables.c @@ -26,20 +26,20 @@ #include "xcb_errors.h" #include "errors.h" -const char *unknown_major_code[256] = { -#define ENTRY(i) "Unknown major code " #i, +const char unknown_major_code[] = { +#define ENTRY(i) "Unknown major code " #i "\0" #include "static_tables.inc" #undef ENTRY }; -const char *unknown_error_code[256] = { -#define ENTRY(i) "Unknown error " #i, +const char unknown_error_code[] = { +#define ENTRY(i) "Unknown error " #i "\0" #include "static_tables.inc" #undef ENTRY }; -const char *unknown_event_code[256] = { -#define ENTRY(i) "Unknown event " #i, +const char unknown_event_code[] = { +#define ENTRY(i) "Unknown event " #i "\0" #include "static_tables.inc" #undef ENTRY }; diff --git a/src/xcb_errors.c b/src/xcb_errors.c index 7cffe85..f33966a 100644 --- a/src/xcb_errors.c +++ b/src/xcb_errors.c @@ -152,7 +152,7 @@ const char *xcb_errors_get_name_for_major_code(xcb_errors_context_t *ctx, info = info->next; if (info == NULL) - return unknown_major_code[major_code]; + return get_strings_entry(unknown_major_code, major_code); return info->name; } @@ -184,7 +184,7 @@ const char *xcb_errors_get_name_for_event(xcb_errors_context_t *ctx, info = info->next; if (info == NULL) - return unknown_event_code[event_code]; + return get_strings_entry(unknown_event_code, event_code); return get_strings_entry(info->static_info.strings_events, event_code - info->first_event); } @@ -201,7 +201,7 @@ const char *xcb_errors_get_name_for_error(xcb_errors_context_t *ctx, info = info->next; if (info == NULL) - return unknown_error_code[error_code]; + return get_strings_entry(unknown_error_code, error_code); return get_strings_entry(info->static_info.strings_errors, error_code - info->first_error); } |