diff options
author | José Fonseca <jose.r.fonseca@gmail.com> | 2013-04-14 11:13:28 +0100 |
---|---|---|
committer | José Fonseca <jose.r.fonseca@gmail.com> | 2013-04-14 11:13:28 +0100 |
commit | 074bbcf12485f3cde22a0c1d194d1d9235f1d2f1 (patch) | |
tree | 066d182543d2ae84fc896a401bce276d0ae57eba /helpers | |
parent | 7cf65aea01b1c573cca814467f1febbc726e6586 (diff) |
gltrace: Respect all string length parameters.
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/glsize.hpp | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/helpers/glsize.hpp b/helpers/glsize.hpp index 77ff8f09..9821b8fb 100644 --- a/helpers/glsize.hpp +++ b/helpers/glsize.hpp @@ -816,31 +816,44 @@ _glClearBuffer_size(GLenum buffer) } -template<class T> +/** + * Helper function for determining the string lengths for glShaderSource and + * glShaderSourceARB, which is a tad too complex to inline in the specs. + */ +template<class Char> static inline size_t -_glStrLen(const T * string, GLsizei length) +_glShaderSource_length(const Char * const * string, const GLint *length, GLsizei index) { - if (length >= 0) { - return length; + if (length != NULL && length[index] >= 0) { + return (size_t)length[index]; } else { - return strlen(string); + return strlen(string[index]); } } - /** - * Helper function for determining the string lengths for glShaderSource and - * glShaderSourceARB, which is a tad too complex to inline in the specs. + * Helper function for determining the string lengths for glGetDebugMessageLog*. */ -template<class T> +template<class Char> static inline size_t -_glShaderSource_length(const T * const * string, const GLint *length, GLsizei index) +_glGetDebugMessageLog_length(const Char * string, const GLsizei *lengths, GLuint count) { - if (length != NULL && length[index] >= 0) { - return (size_t)length[index]; + size_t size = 0; + GLuint index; + if (lengths) { + for (index = 0; index < count; ++index) { + size += lengths[index]; + } } else { - return strlen(string[index]); + for (index = 0; index < count; ++index) { + size += strlen(&string[size]) + 1; + } } + if (size) { + // Remove the last null terminator + --size; + } + return size; } /* |