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>
This commit is contained in:
Uli Schlachter 2015-03-18 22:11:48 +01:00
parent 514070caf8
commit 925ab1e7fb
3 changed files with 12 additions and 12 deletions

View file

@ -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);

View file

@ -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
};

View file

@ -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);
}