(gl) Fix gl_check_error()

gl_check_error() was leaking memory and the error message was never
returned to the calling context.
This commit is contained in:
Higor Eurípedes 2016-09-17 20:55:19 -03:00
parent be6bce0eb0
commit d4305d65d9
4 changed files with 9 additions and 11 deletions

View File

@ -2094,7 +2094,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
gl_init_pbo_readback(gl);
#endif
if (!gl_check_error(error_string))
if (!gl_check_error(&error_string))
{
RARCH_ERR("%s\n", error_string);
free(error_string);

View File

@ -72,31 +72,29 @@ static bool gl_query_extension(const char *ext)
return ret;
}
bool gl_check_error(char *error_string)
bool gl_check_error(char **error_string)
{
int error = glGetError();
switch (error)
{
case GL_INVALID_ENUM:
error_string = strdup("GL: Invalid enum.");
*error_string = strdup("GL: Invalid enum.");
break;
case GL_INVALID_VALUE:
error_string = strdup("GL: Invalid value.");
*error_string = strdup("GL: Invalid value.");
break;
case GL_INVALID_OPERATION:
error_string = strdup("GL: Invalid operation.");
*error_string = strdup("GL: Invalid operation.");
break;
case GL_OUT_OF_MEMORY:
error_string = strdup("GL: Out of memory.");
*error_string = strdup("GL: Out of memory.");
break;
case GL_NO_ERROR:
return true;
default:
error_string = strdup("Non specified GL error.");
*error_string = strdup("Non specified GL error.");
break;
}
(void)error_string;
return false;
}

View File

@ -202,7 +202,7 @@ enum gl_capability_enum
RETRO_BEGIN_DECLS
bool gl_check_error(char *error_string);
bool gl_check_error(char **error_string);
bool gl_query_core_context_in_use(void);

View File

@ -846,7 +846,7 @@ static void *gl_glsl_init(void *data, const char *path)
gl_glsl_find_uniforms(glsl, i, glsl->prg[i].id, &glsl->uniforms[i]);
#ifdef GLSL_DEBUG
if (!gl_check_error(error_string))
if (!gl_check_error(&error_string))
{
RARCH_ERR("%s\n", error_string);
free(error_string);