testshader: use SDL_malloc instead of SDL_stack_alloc.

This commit is contained in:
Ryan C. Gordon 2022-03-26 08:42:09 -04:00
parent d6122704e8
commit beecae31f6
No known key found for this signature in database
GPG Key ID: FA148B892AB48044
1 changed files with 18 additions and 12 deletions

View File

@ -132,15 +132,18 @@ static SDL_bool CompileShader(GLhandleARB shader, const char *source)
glCompileShaderARB(shader); glCompileShaderARB(shader);
glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status); glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status);
if (status == 0) { if (status == 0) {
GLint length; GLint length = 0;
char *info; char *info;
glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
info = SDL_stack_alloc(char, length+1); info = (char *) SDL_malloc(length + 1);
if (!info) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
} else {
glGetInfoLogARB(shader, length, NULL, info); glGetInfoLogARB(shader, length, NULL, info);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to compile shader:\n%s\n%s", source, info); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to compile shader:\n%s\n%s", source, info);
SDL_stack_free(info); SDL_free(info);
}
return SDL_FALSE; return SDL_FALSE;
} else { } else {
return SDL_TRUE; return SDL_TRUE;
@ -157,15 +160,18 @@ static SDL_bool LinkProgram(ShaderData *data)
glGetObjectParameterivARB(data->program, GL_OBJECT_LINK_STATUS_ARB, &status); glGetObjectParameterivARB(data->program, GL_OBJECT_LINK_STATUS_ARB, &status);
if (status == 0) { if (status == 0) {
GLint length; GLint length = 0;
char *info; char *info;
glGetObjectParameterivARB(data->program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); glGetObjectParameterivARB(data->program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length);
info = SDL_stack_alloc(char, length+1); info = (char *) SDL_malloc(length + 1);
if (!info) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
} else {
glGetInfoLogARB(data->program, length, NULL, info); glGetInfoLogARB(data->program, length, NULL, info);
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to link program:\n%s", info); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to link program:\n%s", info);
SDL_stack_free(info); SDL_free(info);
}
return SDL_FALSE; return SDL_FALSE;
} else { } else {
return SDL_TRUE; return SDL_TRUE;