From 7867799c72c3420994389406c5f64263304b74d6 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 27 May 2004 00:05:13 +0000 Subject: Modify glprocs.h to have two tables instead of one. The first table is just a huge string will all the function names in it. The second table contains offsets into the first table instead of pointers to strings. --- src/mesa/glapi/glapi.c | 54 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 14 deletions(-) (limited to 'src/mesa/glapi/glapi.c') diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index aa91583433..d28e7c4a93 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -446,10 +446,28 @@ struct name_address_offset { }; +#define NEED_FUNCTION_POINTER + /* The code in this file is auto-generated with Python */ #include "glprocs.h" +static const glprocs_table_t * +find_entry( const char * n ) +{ + unsigned i; + + for ( i = 0 ; static_functions[i].Name_offset >= 0 ; i++ ) { + const char * test_name; + + test_name = gl_string_table + static_functions[i].Name_offset; + if (strcmp(test_name, n) == 0) { + return & static_functions[i]; + } + } + return NULL; +} + /* * Return dispatch table offset of the named static (built-in) function. @@ -458,11 +476,10 @@ struct name_address_offset { static GLint get_static_proc_offset(const char *funcName) { - GLuint i; - for (i = 0; static_functions[i].Name; i++) { - if (strcmp(static_functions[i].Name, funcName) == 0) { - return static_functions[i].Offset; - } + const glprocs_table_t * const f = find_entry( funcName ); + + if ( f != NULL ) { + return f->Offset; } return -1; } @@ -472,13 +489,22 @@ get_static_proc_offset(const char *funcName) * Return dispatch function address the named static (built-in) function. * Return NULL if function not found. */ -static GLvoid * +static const GLvoid * get_static_proc_address(const char *funcName) { - GLint i; - for (i = 0; static_functions[i].Name; i++) { - if (strcmp(static_functions[i].Name, funcName) == 0) { - return static_functions[i].Address; + const glprocs_table_t * const f = find_entry( funcName ); + return ( f != NULL ) ? f->Address : NULL; +} + + +static const char * +get_static_proc_name( GLuint offset ) +{ + unsigned i; + + for ( i = 0 ; static_functions[i].Name_offset >= 0 ; i++ ) { + if (static_functions[i].Offset == offset) { + return gl_string_table + static_functions[i].Name_offset; } } return NULL; @@ -802,13 +828,13 @@ _glapi_get_proc_address(const char *funcName) const char * _glapi_get_proc_name(GLuint offset) { - const GLuint n = sizeof(static_functions) / sizeof(struct name_address_offset); GLuint i; + const char * n; /* search built-in functions */ - for (i = 0; i < n; i++) { - if (static_functions[i].Offset == offset) - return static_functions[i].Name; + n = get_static_proc_name(offset); + if ( n != NULL ) { + return n; } /* search added extension functions */ -- cgit v1.2.3