Forráskód Böngészése

dynapi: Minor optimization to SDL_SetError wrapper.

Ryan C. Gordon 4 hónapja
szülő
commit
6fe09e3aa4
1 módosított fájl, 4 hozzáadás és 7 törlés
  1. 4 7
      src/dynapi/SDL_dynapi.c

+ 4 - 7
src/dynapi/SDL_dynapi.c

@@ -86,13 +86,10 @@ static void SDL_InitDynamicAPI(void);
         result = jump_table.SDL_vsnprintf(buf, sizeof(buf), fmt, ap);                                                                     \
         va_end(ap);                                                                                                                       \
         if (result >= 0 && (size_t)result >= sizeof(buf)) {                                                                               \
-            size_t len = (size_t)result + 1;                                                                                              \
-            str = (char *)jump_table.SDL_malloc(len);                                                                                     \
-            if (str) {                                                                                                                    \
-                va_start(ap, fmt);                                                                                                        \
-                result = jump_table.SDL_vsnprintf(str, len, fmt, ap);                                                                     \
-                va_end(ap);                                                                                                               \
-            }                                                                                                                             \
+            str = NULL;                                                                                                                   \
+            va_start(ap, fmt);                                                                                                            \
+            result = jump_table.SDL_vasprintf(&str, fmt, ap);                                                                                        \
+            va_end(ap);                                                                                                                   \
         }                                                                                                                                 \
         if (result >= 0) {                                                                                                                \
             jump_table.SDL_SetError("%s", str);                                                                                           \