1 #include <stdlib.h> 2 3 /* void glGetShaderInfoLog ( GLuint shader, GLsizei maxLength, GLsizei* length, GLchar* infoLog ) */ 4 static jstring android_glGetShaderInfoLog(JNIEnv *_env, jobject, jint shader) { 5 GLint infoLen = 0; 6 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen); 7 if (!infoLen) { 8 return _env->NewStringUTF(""); 9 } 10 char* buf = (char*) malloc(infoLen); 11 if (buf == NULL) { 12 jniThrowException(_env, "java/lang/IllegalArgumentException", "out of memory"); 13 return NULL; 14 } 15 glGetShaderInfoLog(shader, infoLen, NULL, buf); 16 jstring result = _env->NewStringUTF(buf); 17 free(buf); 18 return result; 19 } 20