minor cleanup of SDL_CreateRenderer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index c2f100a..f9f01fb 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -930,7 +930,7 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
#endif
if (!window) {
- SDL_SetError("Invalid window");
+ SDL_InvalidParamError("window");
goto error;
}
@@ -979,24 +979,24 @@ SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
}
}
}
- if (index == n) {
+ if (!renderer) {
SDL_SetError("Couldn't find matching render driver");
goto error;
}
} else {
- if (index >= SDL_GetNumRenderDrivers()) {
+ if (index >= n) {
SDL_SetError("index must be -1 or in the range of 0 - %d",
- SDL_GetNumRenderDrivers() - 1);
+ n - 1);
goto error;
}
/* Create a new renderer instance */
renderer = render_drivers[index]->CreateRenderer(window, flags);
batching = SDL_FALSE;
+ if (!renderer) {
+ goto error;
+ }
}
- if (!renderer) {
- goto error;
- }
VerifyDrawQueueFunctions(renderer);