Skip to content

Commit 6cab389

Browse files
committed
Use SDL_asprintf instead of calculating and allocating a buffer.
1 parent 824ff7c commit 6cab389

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

dirksimple_sdl.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,8 @@ void DirkSimple_panic(const char *str)
6868

6969
static DIRKSIMPLE_NORETURN void sdlpanic(const char *what)
7070
{
71-
const char *sdlerr = SDL_GetError();
72-
const size_t slen = SDL_strlen(sdlerr) + SDL_strlen(what) + 32;
73-
char *errstr = SDL_malloc(slen);
74-
if (errstr) {
75-
SDL_snprintf(errstr, slen, "%s: %s", what, SDL_GetError());
76-
}
71+
char *errstr = NULL;
72+
SDL_asprintf(&errstr, "%s: %s", what, SDL_GetError());
7773
DirkSimple_panic(errstr ? errstr : what);
7874
}
7975

0 commit comments

Comments
 (0)