From 889acff2132838bae01a77d216f77a98bfee6358 Mon Sep 17 00:00:00 2001 From: Nigel Stewart Date: Sat, 21 Feb 2015 23:44:08 +1000 Subject: [PATCH] [CoreSupport] Linux/GLX touch-ups for ANSI-C with gcc -pedantic compilation flag --- auto/src/glew_head.c | 12 ++++++++++++ auto/src/glew_init_gl.c | 6 +++--- auto/src/glew_utils.c | 11 +++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/auto/src/glew_head.c b/auto/src/glew_head.c index 80d6cc1..32dc717 100644 --- a/auto/src/glew_head.c +++ b/auto/src/glew_head.c @@ -188,6 +188,7 @@ void* NSGLGetProcAddress (const GLubyte *name) * GLEW, just like OpenGL or GLU, does not rely on the standard C library. * These functions implement the functionality required in this file. */ + static GLuint _glewStrLen (const GLubyte* s) { GLuint i=0; @@ -204,6 +205,17 @@ static GLuint _glewStrCLen (const GLubyte* s, GLubyte c) 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) { GLuint i=0; diff --git a/auto/src/glew_init_gl.c b/auto/src/glew_init_gl.c index c4548ad..890574b 100644 --- a/auto/src/glew_init_gl.c +++ b/auto/src/glew_init_gl.c @@ -140,7 +140,7 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) } else { - const char *ext; + const GLubyte *ext; char *begin; char *end; char *i; @@ -151,8 +151,8 @@ GLenum GLEWAPIENTRY glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST) if (ext) { - begin = strdup(ext); - end = begin + strlen(begin); + begin = (char *) _glewStrDup(ext); + end = begin + _glewStrLen((GLubyte *) begin); for (i=begin; i