Replace check_extension with one that does not anger valgrind.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3766 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2008-02-12 18:57:20 +00:00
parent 21927c7e74
commit 683d9deb2e
1 changed files with 11 additions and 15 deletions

View File

@ -53,29 +53,25 @@ extern BOOL drawing_interface;
* OpenGL extensions for shadows * OpenGL extensions for shadows
*/ */
BOOL check_extension(const char* extension_name) BOOL check_extension(const char *extName)
{ {
const char *extension_list = (const char *)glGetString(GL_EXTENSIONS); char *p = (char *) glGetString(GL_EXTENSIONS);
unsigned int extension_name_length = strlen(extension_name); char *end;
const char *tmp = extension_list; size_t extNameLen= strlen(extName);
unsigned int first_extension_length;
if (!extension_name || !extension_list) return FALSE; end = p + strlen(p);
while (p < end)
while (tmp[0]) { {
first_extension_length = strcspn(tmp, " "); int n = strcspn(p, " ");
if ((extNameLen == n) && (strncmp(extName, p, n) == 0))
if ( extension_name_length == first_extension_length {
&& strncmp(extension_name, tmp, first_extension_length) == 0) {
return TRUE; return TRUE;
} }
tmp += first_extension_length + 1; p += (n + 1);
} }
return FALSE; return FALSE;
} }
// EXT_stencil_two_side // EXT_stencil_two_side
#ifndef GL_EXT_stencil_two_side #ifndef GL_EXT_stencil_two_side
# define GL_EXT_stencil_two_side 1 # define GL_EXT_stencil_two_side 1