mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-02 01:47:41 +00:00
Small stack allocations fall back to malloc if they're unexpectedly large.
This commit is contained in:
parent
eedf2c965d
commit
b262b0ebc9
19 changed files with 84 additions and 52 deletions
|
@ -601,19 +601,20 @@ GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type)
|
|||
compileSuccessful = GL_TRUE;
|
||||
}
|
||||
if (!compileSuccessful) {
|
||||
SDL_bool isstack = SDL_FALSE;
|
||||
char *info = NULL;
|
||||
int length = 0;
|
||||
|
||||
data->glGetShaderiv(entry->id, GL_INFO_LOG_LENGTH, &length);
|
||||
if (length > 0) {
|
||||
info = SDL_stack_alloc(char, length);
|
||||
info = SDL_small_alloc(char, length, &isstack);
|
||||
if (info) {
|
||||
data->glGetShaderInfoLog(entry->id, length, &length, info);
|
||||
}
|
||||
}
|
||||
if (info) {
|
||||
SDL_SetError("Failed to load the shader: %s", info);
|
||||
SDL_stack_free(info);
|
||||
SDL_small_free(info, isstack);
|
||||
} else {
|
||||
SDL_SetError("Failed to load the shader");
|
||||
}
|
||||
|
@ -1814,10 +1815,11 @@ GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
|
||||
/* Flip the rows to be top-down if necessary */
|
||||
if (!renderer->target) {
|
||||
SDL_bool isstack;
|
||||
length = rect->w * SDL_BYTESPERPIXEL(temp_format);
|
||||
src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch;
|
||||
dst = (Uint8*)temp_pixels;
|
||||
tmp = SDL_stack_alloc(Uint8, length);
|
||||
tmp = SDL_small_alloc(Uint8, length, &isstack);
|
||||
rows = rect->h / 2;
|
||||
while (rows--) {
|
||||
SDL_memcpy(tmp, dst, length);
|
||||
|
@ -1826,7 +1828,7 @@ GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
|||
dst += temp_pitch;
|
||||
src -= temp_pitch;
|
||||
}
|
||||
SDL_stack_free(tmp);
|
||||
SDL_small_free(tmp, isstack);
|
||||
}
|
||||
|
||||
status = SDL_ConvertPixels(rect->w, rect->h,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue