[CoreSupport] Linux/GLX touch-ups for ANSI-C with gcc -pedantic compilation flag

This commit is contained in:
Nigel Stewart 2015-02-21 23:44:08 +10:00 committed by Nigel Stewart
parent d1d8e4da71
commit 8a0c6a00cd
3 changed files with 26 additions and 3 deletions

View File

@ -188,6 +188,7 @@ void* NSGLGetProcAddress (const GLubyte *name)
* GLEW, just like OpenGL or GLU, does not rely on the standard C library. * GLEW, just like OpenGL or GLU, does not rely on the standard C library.
* These functions implement the functionality required in this file. * These functions implement the functionality required in this file.
*/ */
static GLuint _glewStrLen (const GLubyte* s) static GLuint _glewStrLen (const GLubyte* s)
{ {
GLuint i=0; GLuint i=0;
@ -204,6 +205,17 @@ static GLuint _glewStrCLen (const GLubyte* s, GLubyte c)
return (s[i] == '\0' || s[i] == c) ? i : 0; return (s[i] == '\0' || s[i] == c) ? i : 0;
} }
static GLubyte *_glewStrDup (const GLubyte *s)
{
int n = _glewStrLen(s) + 1;
GLubyte *dup = malloc(n);
if (dup)
{
strcpy((char *) dup, (const char *) s);
}
return dup;
}
static GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n) static GLboolean _glewStrSame (const GLubyte* a, const GLubyte* b, GLuint n)
{ {
GLuint i=0; GLuint i=0;

View File

@ -140,7 +140,7 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
} }
else else
{ {
const char *ext; const GLubyte *ext;
char *begin; char *begin;
char *end; char *end;
char *i; char *i;
@ -151,8 +151,8 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
if (ext) if (ext)
{ {
begin = strdup(ext); begin = (char *) _glewStrDup(ext);
end = begin + strlen(begin); end = begin + _glewStrLen((GLubyte *) begin);
for (i=begin; i<end; i = j + 1) for (i=begin; i<end; i = j + 1)
{ {
i = _glewNextNonSpace(i); i = _glewNextNonSpace(i);

View File

@ -87,6 +87,17 @@ void* dlGetProcAddress (const GLubyte* name)
* These functions implement the functionality required in this file. * These functions implement the functionality required in this file.
*/ */
static GLubyte *_glewStrDup (const GLubyte *str)
{
int n = strlen(str) + 1;
char *dup = malloc(n);
if (dup)
{
strcpy(dup, str);
}
return dup;
}
GLuint _glewStrLen (const GLubyte* s) GLuint _glewStrLen (const GLubyte* s)
{ {
GLuint i=0; GLuint i=0;