diff options
| author | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2025-10-20 19:44:46 +0200 |
|---|---|---|
| committer | Drew DeVault <drew@ddevault.org> | 2025-10-21 09:35:37 +0200 |
| commit | fb6008be0b79a2a24b1ac960316a83f7873b4f39 (patch) | |
| tree | ecc633c0dbfbc72422fbec5f66af639a7ee2b8be | |
| parent | sdl2/rwops: assert on allocation failure (diff) | |
| download | hare-chip8-fb6008be0b79a2a24b1ac960316a83f7873b4f39.tar.gz | |
Add ! after c::fromstr calls to handle nomem
Lazy way out, might be better to change API either by returning
nomem or using `*char` as parameter so it's caller controlled
instead of `str`.
| -rw-r--r-- | sdl2/image/image.ha | 4 | ||||
| -rw-r--r-- | sdl2/keyboard.ha | 2 | ||||
| -rw-r--r-- | sdl2/video.ha | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/sdl2/image/image.ha b/sdl2/image/image.ha index 32f8f3d..b4af99e 100644 --- a/sdl2/image/image.ha +++ b/sdl2/image/image.ha @@ -27,7 +27,7 @@ export @symbol("IMG_Quit") fn IMG_Quit() void; // Load an image from a file path. export fn IMG_Load(file: str) (*sdl2::SDL_Surface | sdl2::error) = { - const file = c::fromstr(file); + const file = c::fromstr(file)!; defer free(file); return sdl2::wrapptr(_IMG_Load(file))?: *sdl2::SDL_Surface; }; @@ -40,7 +40,7 @@ export fn IMG_LoadTexture( SDL_Renderer: *sdl2::SDL_Renderer, file: str, ) (*sdl2::SDL_Texture | sdl2::error) = { - const file = c::fromstr(file); + const file = c::fromstr(file)!; defer free(file); return sdl2::wrapptr(_IMG_LoadTexture(SDL_Renderer, file))?: *sdl2::SDL_Texture; }; diff --git a/sdl2/keyboard.ha b/sdl2/keyboard.ha index b9759dd..02cedae 100644 --- a/sdl2/keyboard.ha +++ b/sdl2/keyboard.ha @@ -635,7 +635,7 @@ export type SDL_Keysym = struct { @symbol("SDL_GetKeyFromName") fn _SDL_GetKeyFromName(name: *const c::char) SDL_Keycode; export fn SDL_GetKeyFromName(name: str) (SDL_Keycode | error) = { - const name = c::fromstr(name); + const name = c::fromstr(name)!; defer free(name); const sym = _SDL_GetKeyFromName(name); if (sym == SDL_Keycode::UNKNOWN) { diff --git a/sdl2/video.ha b/sdl2/video.ha index 2627b48..72ed96f 100644 --- a/sdl2/video.ha +++ b/sdl2/video.ha @@ -78,7 +78,7 @@ export fn SDL_CreateWindow( h: int, flags: SDL_WindowFlags, ) (*SDL_Window | error) = { - let title = c::fromstr(title); + let title = c::fromstr(title)!; defer free(title); return wrapptr(_SDL_CreateWindow(title, x, y, w, h, flags))?: *SDL_Window; }; |
