Prechádzať zdrojové kódy

error: SDL's allocators now call SDL_OutOfMemory on error.

This means the allocator's caller doesn't need to use SDL_OutOfMemory directly
if the allocation fails.

This applies to the usual allocators: SDL_malloc, SDL_calloc, SDL_realloc
(all of these regardless of if the app supplied a custom allocator or we're
using system malloc() or an internal copy of dlmalloc under the hood),
SDL_aligned_alloc, SDL_small_alloc, SDL_strdup, SDL_asprintf, SDL_wcsdup...
probably others. If it returns something you can pass to SDL_free, it should
work.

The caller might still need to use SDL_OutOfMemory if something that wasn't
SDL allocated the memory: operator new in C++ code, Objective-C's alloc
message, win32 GlobalAlloc, etc.

Fixes #8642.
Ryan C. Gordon 1 rok pred
rodič
commit
447b508a77
100 zmenil súbory, kde vykonal 204 pridanie a 417 odobranie
  1. 0 3
      src/SDL_hashtable.c
  2. 3 3
      src/SDL_hints.c
  3. 1 1
      src/SDL_list.c
  4. 7 11
      src/SDL_properties.c
  5. 5 11
      src/audio/SDL_audio.c
  6. 2 6
      src/audio/SDL_audiocvt.c
  7. 3 5
      src/audio/SDL_audioqueue.c
  8. 15 15
      src/audio/SDL_wave.c
  9. 2 2
      src/audio/aaudio/SDL_aaudio.c
  10. 2 2
      src/audio/alsa/SDL_alsa_audio.c
  11. 1 1
      src/audio/android/SDL_androidaudio.c
  12. 2 2
      src/audio/coreaudio/SDL_coreaudio.m
  13. 1 1
      src/audio/directsound/SDL_directsound.c
  14. 2 2
      src/audio/disk/SDL_diskaudio.c
  15. 2 2
      src/audio/dsp/SDL_dspaudio.c
  16. 2 2
      src/audio/dummy/SDL_dummyaudio.c
  17. 2 2
      src/audio/emscripten/SDL_emscriptenaudio.c
  18. 3 3
      src/audio/jack/SDL_jackaudio.c
  19. 2 2
      src/audio/n3ds/SDL_n3dsaudio.c
  20. 2 2
      src/audio/netbsd/SDL_netbsdaudio.c
  21. 1 1
      src/audio/openslES/SDL_openslES.c
  22. 1 2
      src/audio/pipewire/SDL_pipewire.c
  23. 1 1
      src/audio/ps2/SDL_ps2audio.c
  24. 1 1
      src/audio/psp/SDL_pspaudio.c
  25. 2 2
      src/audio/pulseaudio/SDL_pulseaudio.c
  26. 2 2
      src/audio/qnx/SDL_qsa_audio.c
  27. 3 3
      src/audio/sndio/SDL_sndioaudio.c
  28. 2 3
      src/audio/vita/SDL_vitaaudio.c
  29. 2 2
      src/audio/wasapi/SDL_wasapi.c
  30. 6 6
      src/core/linux/SDL_evdev.c
  31. 2 2
      src/core/linux/SDL_udev.c
  32. 0 2
      src/core/windows/SDL_immdevice.c
  33. 0 3
      src/events/SDL_events.c
  34. 1 4
      src/events/SDL_mouse.c
  35. 5 7
      src/events/SDL_touch.c
  36. 2 7
      src/file/SDL_rwops.c
  37. 0 1
      src/file/n3ds/SDL_rwopsromfs.c
  38. 0 1
      src/filesystem/android/SDL_sysfilesystem.c
  39. 3 14
      src/filesystem/cocoa/SDL_sysfilesystem.m
  40. 1 9
      src/filesystem/emscripten/SDL_sysfilesystem.c
  41. 0 1
      src/filesystem/gdk/SDL_sysfilesystem.cpp
  42. 5 16
      src/filesystem/haiku/SDL_sysfilesystem.cc
  43. 0 1
      src/filesystem/n3ds/SDL_sysfilesystem.c
  44. 0 3
      src/filesystem/riscos/SDL_sysfilesystem.c
  45. 1 14
      src/filesystem/unix/SDL_sysfilesystem.c
  46. 0 1
      src/filesystem/vita/SDL_sysfilesystem.c
  47. 0 3
      src/filesystem/windows/SDL_sysfilesystem.c
  48. 0 3
      src/filesystem/winrt/SDL_sysfilesystem.cpp
  49. 0 2
      src/haptic/SDL_haptic.c
  50. 0 1
      src/haptic/android/SDL_syshaptic.c
  51. 16 27
      src/haptic/darwin/SDL_syshaptic.c
  52. 3 6
      src/haptic/linux/SDL_syshaptic.c
  53. 17 25
      src/haptic/windows/SDL_dinputhaptic.c
  54. 1 4
      src/haptic/windows/SDL_windowshaptic.c
  55. 5 8
      src/haptic/windows/SDL_xinputhaptic.c
  56. 3 24
      src/joystick/SDL_gamepad.c
  57. 0 5
      src/joystick/SDL_joystick.c
  58. 0 2
      src/joystick/apple/SDL_mfijoystick.m
  59. 1 2
      src/joystick/bsd/SDL_bsdjoystick.c
  60. 1 2
      src/joystick/darwin/SDL_iokitjoystick.c
  61. 5 9
      src/joystick/haiku/SDL_haikujoystick.cc
  62. 0 1
      src/joystick/hidapi/SDL_hidapi_gamecube.c
  63. 0 1
      src/joystick/hidapi/SDL_hidapi_luna.c
  64. 0 2
      src/joystick/hidapi/SDL_hidapi_ps3.c
  65. 0 1
      src/joystick/hidapi/SDL_hidapi_ps4.c
  66. 0 1
      src/joystick/hidapi/SDL_hidapi_ps5.c
  67. 1 1
      src/joystick/hidapi/SDL_hidapi_rumble.c
  68. 0 1
      src/joystick/hidapi/SDL_hidapi_shield.c
  69. 0 1
      src/joystick/hidapi/SDL_hidapi_stadia.c
  70. 0 1
      src/joystick/hidapi/SDL_hidapi_steam.c
  71. 0 1
      src/joystick/hidapi/SDL_hidapi_switch.c
  72. 0 1
      src/joystick/hidapi/SDL_hidapi_wii.c
  73. 0 1
      src/joystick/hidapi/SDL_hidapi_xbox360.c
  74. 0 1
      src/joystick/hidapi/SDL_hidapi_xbox360w.c
  75. 0 1
      src/joystick/hidapi/SDL_hidapi_xboxone.c
  76. 1 1
      src/joystick/hidapi/SDL_hidapijoystick.c
  77. 2 4
      src/joystick/linux/SDL_sysjoystick.c
  78. 4 4
      src/joystick/virtual/SDL_virtualjoystick.c
  79. 1 1
      src/joystick/windows/SDL_dinputjoystick.c
  80. 7 7
      src/joystick/windows/SDL_rawinputjoystick.c
  81. 1 2
      src/joystick/windows/SDL_windows_gaming_input.c
  82. 2 4
      src/joystick/windows/SDL_windowsjoystick.c
  83. 0 1
      src/locale/SDL_locale.c
  84. 1 1
      src/locale/unix/SDL_syslocale.c
  85. 1 1
      src/locale/windows/SDL_syslocale.c
  86. 1 1
      src/misc/windows/SDL_sysurl.c
  87. 1 1
      src/misc/winrt/SDL_sysurl.cpp
  88. 8 11
      src/render/SDL_render.c
  89. 0 3
      src/render/SDL_yuv_sw.c
  90. 2 4
      src/render/direct3d/SDL_render_d3d.c
  91. 1 5
      src/render/direct3d11/SDL_render_d3d11.c
  92. 1 5
      src/render/direct3d12/SDL_render_d3d12.c
  93. 1 4
      src/render/metal/SDL_render_metal.m
  94. 3 5
      src/render/opengl/SDL_render_gl.c
  95. 4 7
      src/render/opengles2/SDL_render_gles2.c
  96. 2 4
      src/render/ps2/SDL_render_ps2.c
  97. 5 7
      src/render/psp/SDL_render_psp.c
  98. 0 2
      src/render/software/SDL_render_sw.c
  99. 2 4
      src/render/vitagxm/SDL_render_vita_gxm.c
  100. 0 3
      src/sensor/SDL_sensor.c

+ 0 - 3
src/SDL_hashtable.c

@@ -54,14 +54,12 @@ SDL_HashTable *SDL_CreateHashTable(void *data, const Uint32 num_buckets, const S
 
     table = (SDL_HashTable *) SDL_calloc(1, sizeof (SDL_HashTable));
     if (!table) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
     table->table = (SDL_HashItem **) SDL_calloc(num_buckets, sizeof (SDL_HashItem *));
     if (!table->table) {
         SDL_free(table);
-        SDL_OutOfMemory();
         return NULL;
     }
 
@@ -92,7 +90,6 @@ SDL_bool SDL_InsertIntoHashTable(SDL_HashTable *table, const void *key, const vo
     // !!! FIXME: grow and rehash table if it gets too saturated.
     item = (SDL_HashItem *) SDL_malloc(sizeof (SDL_HashItem));
     if (!item) {
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
 

+ 3 - 3
src/SDL_hints.c

@@ -226,7 +226,7 @@ int SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userd
 
     entry = (SDL_HintWatch *)SDL_malloc(sizeof(*entry));
     if (!entry) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     entry->callback = callback;
     entry->userdata = userdata;
@@ -241,13 +241,13 @@ int SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userd
         hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
         if (!hint) {
             SDL_free(entry);
-            return SDL_OutOfMemory();
+            return -1;
         }
         hint->name = SDL_strdup(name);
         if (!hint->name) {
             SDL_free(entry);
             SDL_free(hint);
-            return SDL_OutOfMemory();
+            return -1;
         }
         hint->value = NULL;
         hint->priority = SDL_HINT_DEFAULT;

+ 1 - 1
src/SDL_list.c

@@ -28,7 +28,7 @@ int SDL_ListAdd(SDL_ListNode **head, void *ent)
     SDL_ListNode *node = SDL_malloc(sizeof(*node));
 
     if (!node) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     node->entry = ent;

+ 7 - 11
src/SDL_properties.c

@@ -271,7 +271,7 @@ int SDL_SetPropertyWithCleanup(SDL_PropertiesID props, const char *name, void *v
 
     property = (SDL_Property *)SDL_calloc(1, sizeof(*property));
     if (!property) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     property->type = SDL_PROPERTY_TYPE_POINTER;
     property->value.pointer_value = value;
@@ -290,7 +290,7 @@ int SDL_SetProperty(SDL_PropertiesID props, const char *name, void *value)
 
     property = (SDL_Property *)SDL_calloc(1, sizeof(*property));
     if (!property) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     property->type = SDL_PROPERTY_TYPE_POINTER;
     property->value.pointer_value = value;
@@ -308,13 +308,13 @@ int SDL_SetStringProperty(SDL_PropertiesID props, const char *name, const char *
 
     property = (SDL_Property *)SDL_calloc(1, sizeof(*property));
     if (!property) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     property->type = SDL_PROPERTY_TYPE_STRING;
     property->value.string_value = SDL_strdup(value);
     if (!property->value.string_value) {
         SDL_free(property);
-        return SDL_OutOfMemory();
+        return -1;
     }
     return SDL_PrivateSetProperty(props, name, property);
 }
@@ -323,7 +323,7 @@ int SDL_SetNumberProperty(SDL_PropertiesID props, const char *name, Sint64 value
 {
     SDL_Property *property = (SDL_Property *)SDL_calloc(1, sizeof(*property));
     if (!property) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     property->type = SDL_PROPERTY_TYPE_NUMBER;
     property->value.number_value = value;
@@ -334,7 +334,7 @@ int SDL_SetFloatProperty(SDL_PropertiesID props, const char *name, float value)
 {
     SDL_Property *property = (SDL_Property *)SDL_calloc(1, sizeof(*property));
     if (!property) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     property->type = SDL_PROPERTY_TYPE_FLOAT;
     property->value.float_value = value;
@@ -345,7 +345,7 @@ int SDL_SetBooleanProperty(SDL_PropertiesID props, const char *name, SDL_bool va
 {
     SDL_Property *property = (SDL_Property *)SDL_calloc(1, sizeof(*property));
     if (!property) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     property->type = SDL_PROPERTY_TYPE_BOOLEAN;
     property->value.boolean_value = value ? SDL_TRUE : SDL_FALSE;
@@ -478,8 +478,6 @@ const char *SDL_GetStringProperty(SDL_PropertiesID props, const char *name, cons
                     SDL_asprintf(&property->string_storage, "%" SDL_PRIs64 "", property->value.number_value);
                     if (property->string_storage) {
                         value = property->string_storage;
-                    } else {
-                        SDL_OutOfMemory();
                     }
                 }
                 break;
@@ -490,8 +488,6 @@ const char *SDL_GetStringProperty(SDL_PropertiesID props, const char *name, cons
                     SDL_asprintf(&property->string_storage, "%f", property->value.float_value);
                     if (property->string_storage) {
                         value = property->string_storage;
-                    } else {
-                        SDL_OutOfMemory();
                     }
                 }
                 break;

+ 5 - 11
src/audio/SDL_audio.c

@@ -512,14 +512,12 @@ static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, SDL_bool isc
 
     SDL_AudioDevice *device = (SDL_AudioDevice *)SDL_calloc(1, sizeof(SDL_AudioDevice));
     if (!device) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
     device->name = SDL_strdup(name);
     if (!device->name) {
         SDL_free(device);
-        SDL_OutOfMemory();
         return NULL;
     }
 
@@ -840,7 +838,7 @@ int SDL_InitAudio(const char *driver_name)
         if (!driver_name_copy) {
             SDL_DestroyRWLock(device_hash_lock);
             SDL_DestroyHashTable(device_hash);
-            return SDL_OutOfMemory();
+            return -1;
         }
 
         while (driver_attempt && *driver_attempt != 0 && !initialized) {
@@ -1272,7 +1270,6 @@ static SDL_AudioDeviceID *GetAudioDevices(int *reqcount, SDL_bool iscapture)
         retval = (SDL_AudioDeviceID *) SDL_malloc((num_devices + 1) * sizeof (SDL_AudioDeviceID));
         if (!retval) {
             num_devices = 0;
-            SDL_OutOfMemory();
         } else {
             int devs_seen = 0;
             const void *key;
@@ -1360,9 +1357,6 @@ char *SDL_GetAudioDeviceName(SDL_AudioDeviceID devid)
     SDL_AudioDevice *device = ObtainPhysicalAudioDevice(devid);
     if (device) {
         retval = SDL_strdup(device->name);
-        if (!retval) {
-            SDL_OutOfMemory();
-        }
     }
     ReleaseAudioDevice(device);
 
@@ -1574,14 +1568,14 @@ static int OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec
     device->work_buffer = (Uint8 *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), device->work_buffer_size);
     if (!device->work_buffer) {
         ClosePhysicalAudioDevice(device);
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     if (device->spec.format != SDL_AUDIO_F32) {
         device->mix_buffer = (Uint8 *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), device->work_buffer_size);
         if (!device->mix_buffer) {
             ClosePhysicalAudioDevice(device);
-            return SDL_OutOfMemory();
+            return -1;
         }
     }
 
@@ -1630,7 +1624,7 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp
             // uhoh, this device is undead, and just waiting to be cleaned up. Refuse explicit opens.
             SDL_SetError("Device was already lost and can't accept new opens");
         } else if ((logdev = (SDL_LogicalAudioDevice *) SDL_calloc(1, sizeof (SDL_LogicalAudioDevice))) == NULL) {
-            SDL_OutOfMemory();
+            /* SDL_calloc already called SDL_OutOfMemory */
         } else if (OpenPhysicalAudioDevice(device, spec) == -1) {  // if this is the first thing using this physical device, open at the OS level if necessary...
             SDL_free(logdev);
         } else {
@@ -1704,7 +1698,7 @@ int SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid, SDL_AudioPostmixCallbac
         if (callback && !device->postmix_buffer) {
             device->postmix_buffer = (float *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), device->work_buffer_size);
             if (!device->postmix_buffer) {
-                retval = SDL_OutOfMemory();
+                retval = -1;
             }
         }
 

+ 2 - 6
src/audio/SDL_audiocvt.c

@@ -389,7 +389,7 @@ static int UpdateAudioStreamInputSpec(SDL_AudioStream *stream, const SDL_AudioSp
     if (stream->history_buffer_allocation < history_buffer_allocation) {
         history_buffer = (Uint8 *) SDL_aligned_alloc(SDL_SIMDGetAlignment(), history_buffer_allocation);
         if (!history_buffer) {
-            return SDL_OutOfMemory();
+            return -1;
         }
         SDL_aligned_free(stream->history_buffer);
         stream->history_buffer = history_buffer;
@@ -409,7 +409,6 @@ SDL_AudioStream *SDL_CreateAudioStream(const SDL_AudioSpec *src_spec, const SDL_
 
     SDL_AudioStream *retval = (SDL_AudioStream *)SDL_calloc(1, sizeof(SDL_AudioStream));
     if (!retval) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
@@ -722,7 +721,6 @@ static Uint8 *EnsureAudioStreamWorkBufferSize(SDL_AudioStream *stream, size_t ne
 
     Uint8 *ptr = (Uint8 *) SDL_aligned_alloc(SDL_SIMDGetAlignment(), newlen);
     if (!ptr) {
-        SDL_OutOfMemory();
         return NULL;  // previous work buffer is still valid!
     }
 
@@ -1234,9 +1232,7 @@ int SDL_ConvertAudioSamples(const SDL_AudioSpec *src_spec, const Uint8 *src_data
             dstlen = SDL_GetAudioStreamAvailable(stream);
             if (dstlen >= 0) {
                 dst = (Uint8 *)SDL_malloc(dstlen);
-                if (!dst) {
-                    SDL_OutOfMemory();
-                } else {
+                if (dst) {
                     retval = (SDL_GetAudioStreamData(stream, dst, dstlen) >= 0) ? 0 : -1;
                 }
             }

+ 3 - 5
src/audio/SDL_audioqueue.c

@@ -150,7 +150,7 @@ static int WriteToChunkedAudioTrack(void *ctx, const Uint8 *data, size_t len)
         chunk = CreateAudioTrackChunk(track);
 
         if (!chunk) {
-            return SDL_OutOfMemory();
+            return -1;
         }
 
         SDL_assert((track->head == NULL) && (track->tail == NULL) && (track->queued_bytes == 0));
@@ -189,7 +189,7 @@ static int WriteToChunkedAudioTrack(void *ctx, const Uint8 *data, size_t len)
 
         DestroyAudioChunks(next);
 
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     track->tail = chunk;
@@ -256,7 +256,6 @@ static SDL_AudioTrack *CreateChunkedAudioTrack(const SDL_AudioSpec *spec, size_t
     SDL_ChunkedAudioTrack *track = (SDL_ChunkedAudioTrack *)SDL_calloc(1, sizeof(*track));
 
     if (!track) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
@@ -276,7 +275,6 @@ SDL_AudioQueue *SDL_CreateAudioQueue(size_t chunk_size)
     SDL_AudioQueue *queue = (SDL_AudioQueue *)SDL_calloc(1, sizeof(*queue));
 
     if (!queue) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
@@ -398,7 +396,7 @@ int SDL_WriteToAudioQueue(SDL_AudioQueue *queue, const SDL_AudioSpec *spec, cons
         SDL_AudioTrack *new_track = CreateChunkedAudioTrack(spec, queue->chunk_size);
 
         if (!new_track) {
-            return SDL_OutOfMemory();
+            return -1;
         }
 
         if (track) {

+ 15 - 15
src/audio/SDL_wave.c

@@ -440,7 +440,7 @@ static int MS_ADPCM_Init(WaveFile *file, size_t datalength)
     coeffdata = (MS_ADPCM_CoeffData *)SDL_malloc(sizeof(MS_ADPCM_CoeffData) + coeffcount * 4);
     file->decoderdata = coeffdata; /* Freed in cleanup. */
     if (!coeffdata) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     coeffdata->coeff = &coeffdata->aligndummy;
     coeffdata->coeffcount = (Uint16)coeffcount;
@@ -674,7 +674,7 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
     /* The output size in bytes. May get modified if data is truncated. */
     outputsize = (size_t)state.framestotal;
     if (SafeMult(&outputsize, state.framesize)) {
-        return SDL_OutOfMemory();
+        return SDL_SetError("WAVE file too big");
     } else if (outputsize > SDL_MAX_UINT32 || state.framestotal > SIZE_MAX) {
         return SDL_SetError("WAVE file too big");
     }
@@ -683,7 +683,7 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
     state.output.size = outputsize / sizeof(Sint16);
     state.output.data = (Sint16 *)SDL_calloc(1, outputsize);
     if (!state.output.data) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     state.cstate = cstate;
@@ -1065,7 +1065,7 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len
     /* The output size in bytes. May get modified if data is truncated. */
     outputsize = (size_t)state.framestotal;
     if (SafeMult(&outputsize, state.framesize)) {
-        return SDL_OutOfMemory();
+        return SDL_SetError("WAVE file too big");
     } else if (outputsize > SDL_MAX_UINT32 || state.framestotal > SIZE_MAX) {
         return SDL_SetError("WAVE file too big");
     }
@@ -1074,13 +1074,13 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len
     state.output.size = outputsize / sizeof(Sint16);
     state.output.data = (Sint16 *)SDL_malloc(outputsize);
     if (!state.output.data) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     cstate = (Sint8 *)SDL_calloc(state.channels, sizeof(Sint8));
     if (!cstate) {
         SDL_free(state.output.data);
-        return SDL_OutOfMemory();
+        return -1;
     }
     state.cstate = cstate;
 
@@ -1221,12 +1221,12 @@ static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
 
     sample_count = (size_t)file->sampleframes;
     if (SafeMult(&sample_count, format->channels)) {
-        return SDL_OutOfMemory();
+        return SDL_SetError("WAVE file too big");
     }
 
     expanded_len = sample_count;
     if (SafeMult(&expanded_len, sizeof(Sint16))) {
-        return SDL_OutOfMemory();
+        return SDL_SetError("WAVE file too big");
     } else if (expanded_len > SDL_MAX_UINT32 || file->sampleframes > SIZE_MAX) {
         return SDL_SetError("WAVE file too big");
     }
@@ -1234,7 +1234,7 @@ static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
     /* 1 to avoid allocating zero bytes, to keep static analysis happy. */
     src = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1);
     if (!src) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     chunk->data = NULL;
     chunk->size = 0;
@@ -1352,12 +1352,12 @@ static int PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *
 
     sample_count = (size_t)file->sampleframes;
     if (SafeMult(&sample_count, format->channels)) {
-        return SDL_OutOfMemory();
+        return SDL_SetError("WAVE file too big");
     }
 
     expanded_len = sample_count;
     if (SafeMult(&expanded_len, sizeof(Sint32))) {
-        return SDL_OutOfMemory();
+        return SDL_SetError("WAVE file too big");
     } else if (expanded_len > SDL_MAX_UINT32 || file->sampleframes > SIZE_MAX) {
         return SDL_SetError("WAVE file too big");
     }
@@ -1365,7 +1365,7 @@ static int PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *
     /* 1 to avoid allocating zero bytes, to keep static analysis happy. */
     ptr = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1);
     if (!ptr) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     /* This pointer is now invalid. */
@@ -1421,7 +1421,7 @@ static int PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
 
     outputsize = (size_t)file->sampleframes;
     if (SafeMult(&outputsize, format->blockalign)) {
-        return SDL_OutOfMemory();
+        return SDL_SetError("WAVE file too big");
     } else if (outputsize > SDL_MAX_UINT32 || file->sampleframes > SIZE_MAX) {
         return SDL_SetError("WAVE file too big");
     }
@@ -1545,7 +1545,7 @@ static int WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t len
     if (length > 0) {
         chunk->data = (Uint8 *)SDL_malloc(length);
         if (!chunk->data) {
-            return SDL_OutOfMemory();
+            return -1;
         }
 
         if (SDL_RWseek(src, chunk->position, SDL_RW_SEEK_SET) != chunk->position) {
@@ -1611,7 +1611,7 @@ static int WaveReadFormat(WaveFile *file)
     }
     fmtsrc = SDL_RWFromConstMem(chunk->data, (int)chunk->size);
     if (!fmtsrc) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     if (!SDL_ReadU16LE(fmtsrc, &format->formattag) ||

+ 2 - 2
src/audio/aaudio/SDL_aaudio.c

@@ -355,7 +355,7 @@ static int BuildAAudioStream(SDL_AudioDevice *device)
     hidden->mixbuf_bytes = (hidden->num_buffers * device->buffer_size);
     hidden->mixbuf = (Uint8 *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), hidden->mixbuf_bytes);
     if (!hidden->mixbuf) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     hidden->processed_bytes = 0;
     hidden->callback_bytes = 0;
@@ -398,7 +398,7 @@ static int AAUDIO_OpenDevice(SDL_AudioDevice *device)
 
     device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     return BuildAAudioStream(device);

+ 2 - 2
src/audio/alsa/SDL_alsa_audio.c

@@ -537,7 +537,7 @@ static int ALSA_OpenDevice(SDL_AudioDevice *device)
     // Initialize all variables that we clean on shutdown
     device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     // Open the audio device
@@ -683,7 +683,7 @@ static int ALSA_OpenDevice(SDL_AudioDevice *device)
     if (!iscapture) {
         device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size);
         if (!device->hidden->mixbuf) {
-            return SDL_OutOfMemory();
+            return -1;
         }
         SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size);
     }

+ 1 - 1
src/audio/android/SDL_androidaudio.c

@@ -43,7 +43,7 @@ static int ANDROIDAUDIO_OpenDevice(SDL_AudioDevice *device)
 {
     device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     const SDL_bool iscapture = device->iscapture;

+ 2 - 2
src/audio/coreaudio/SDL_coreaudio.m

@@ -769,7 +769,7 @@ static int PrepareAudioQueue(SDL_AudioDevice *device)
     device->hidden->numAudioBuffers = numAudioBuffers;
     device->hidden->audioBuffer = SDL_calloc(numAudioBuffers, sizeof(AudioQueueBufferRef));
     if (device->hidden->audioBuffer == NULL) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     #if DEBUG_COREAUDIO
@@ -833,7 +833,7 @@ static int COREAUDIO_OpenDevice(SDL_AudioDevice *device)
     // Initialize all variables that we clean on shutdown
     device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
     if (device->hidden == NULL) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     #ifndef MACOSX_COREAUDIO

+ 1 - 1
src/audio/directsound/SDL_directsound.c

@@ -492,7 +492,7 @@ static int DSOUND_OpenDevice(SDL_AudioDevice *device)
     // Initialize all variables that we clean on shutdown
     device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     // Open the audio device

+ 2 - 2
src/audio/disk/SDL_diskaudio.c

@@ -113,7 +113,7 @@ static int DISKAUDIO_OpenDevice(SDL_AudioDevice *device)
 
     device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     if (envr) {
@@ -132,7 +132,7 @@ static int DISKAUDIO_OpenDevice(SDL_AudioDevice *device)
     if (!iscapture) {
         device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size);
         if (!device->hidden->mixbuf) {
-            return SDL_OutOfMemory();
+            return -1;
         }
         SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size);
     }

+ 2 - 2
src/audio/dsp/SDL_dspaudio.c

@@ -71,7 +71,7 @@ static int DSP_OpenDevice(SDL_AudioDevice *device)
     // Initialize all variables that we clean on shutdown
     device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     // Open the audio device; we hardcode the device path in `device->name` for lack of better info, so use that.
@@ -192,7 +192,7 @@ static int DSP_OpenDevice(SDL_AudioDevice *device)
     if (!device->iscapture) {
         device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size);
         if (!device->hidden->mixbuf) {
-            return SDL_OutOfMemory();
+            return -1;
         }
         SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size);
     }

+ 2 - 2
src/audio/dummy/SDL_dummyaudio.c

@@ -40,13 +40,13 @@ static int DUMMYAUDIO_OpenDevice(SDL_AudioDevice *device)
 
     device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     if (!device->iscapture) {
         device->hidden->mixbuf = (Uint8 *) SDL_malloc(device->buffer_size);
         if (!device->hidden->mixbuf) {
-            return SDL_OutOfMemory();
+            return -1;
         }
     }
 

+ 2 - 2
src/audio/emscripten/SDL_emscriptenaudio.c

@@ -178,7 +178,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(SDL_AudioDevice *device)
     // Initialize all variables that we clean on shutdown
     device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     // limit to native freq
@@ -189,7 +189,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(SDL_AudioDevice *device)
     if (!device->iscapture) {
         device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size);
         if (!device->hidden->mixbuf) {
-            return SDL_OutOfMemory();
+            return -1;
         }
         SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size);
     }

+ 3 - 3
src/audio/jack/SDL_jackaudio.c

@@ -297,7 +297,7 @@ static int JACK_OpenDevice(SDL_AudioDevice *device)
     // Initialize all variables that we clean on shutdown
     device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     client = JACK_jack_client_open(GetJackAppName(), JackNoStartServer, &status, NULL);
@@ -343,7 +343,7 @@ static int JACK_OpenDevice(SDL_AudioDevice *device)
         device->hidden->iobuffer = (float *)SDL_calloc(1, device->buffer_size);
         if (!device->hidden->iobuffer) {
             SDL_free(audio_ports);
-            return SDL_OutOfMemory();
+            return -1;
         }
     }
 
@@ -351,7 +351,7 @@ static int JACK_OpenDevice(SDL_AudioDevice *device)
     device->hidden->sdlports = (jack_port_t **)SDL_calloc(channels, sizeof(jack_port_t *));
     if (!device->hidden->sdlports) {
         SDL_free(audio_ports);
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     for (i = 0; i < channels; i++) {

+ 2 - 2
src/audio/n3ds/SDL_n3dsaudio.c

@@ -84,7 +84,7 @@ static int N3DSAUDIO_OpenDevice(SDL_AudioDevice *device)
 
     device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     // Initialise the DSP service
@@ -135,7 +135,7 @@ static int N3DSAUDIO_OpenDevice(SDL_AudioDevice *device)
 
     device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size);
     if (!device->hidden->mixbuf) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size);

+ 2 - 2
src/audio/netbsd/SDL_netbsdaudio.c

@@ -216,7 +216,7 @@ static int NETBSDAUDIO_OpenDevice(SDL_AudioDevice *device)
     // Initialize all variables that we clean on shutdown
     device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     // Open the audio device; we hardcode the device path in `device->name` for lack of better info, so use that.
@@ -294,7 +294,7 @@ static int NETBSDAUDIO_OpenDevice(SDL_AudioDevice *device)
         device->hidden->mixlen = device->buffer_size;
         device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->hidden->mixlen);
         if (!device->hidden->mixbuf) {
-            return SDL_OutOfMemory();
+            return -1;
         }
         SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size);
     }

+ 1 - 1
src/audio/openslES/SDL_openslES.c

@@ -600,7 +600,7 @@ static int OPENSLES_OpenDevice(SDL_AudioDevice *device)
 {
     device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     if (device->iscapture) {

+ 1 - 2
src/audio/pipewire/SDL_pipewire.c

@@ -689,7 +689,6 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p
                 node->userdata = io = SDL_calloc(1, sizeof(struct io_node) + desc_buffer_len + path_buffer_len);
                 if (!io) {
                     node_object_destroy(node);
-                    SDL_OutOfMemory();
                     return;
                 }
 
@@ -1105,7 +1104,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device)
     priv = SDL_calloc(1, sizeof(struct SDL_PrivateAudioData));
     device->hidden = priv;
     if (!priv) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     // Size of a single audio frame in bytes

+ 1 - 1
src/audio/ps2/SDL_ps2audio.c

@@ -31,7 +31,7 @@ static int PS2AUDIO_OpenDevice(SDL_AudioDevice *device)
 {
     device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     // These are the native supported audio PS2 configs

+ 1 - 1
src/audio/psp/SDL_pspaudio.c

@@ -42,7 +42,7 @@ static int PSPAUDIO_OpenDevice(SDL_AudioDevice *device)
 {
     device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     // device only natively supports S16LSB

+ 2 - 2
src/audio/pulseaudio/SDL_pulseaudio.c

@@ -615,7 +615,7 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
     // Initialize all variables that we clean on shutdown
     h = device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     // Try for a closest match on audio format
@@ -664,7 +664,7 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device)
     if (!iscapture) {
         h->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size);
         if (!h->mixbuf) {
-            return SDL_OutOfMemory();
+            return -1;
         }
         SDL_memset(h->mixbuf, device->silence_value, device->buffer_size);
     }

+ 2 - 2
src/audio/qnx/SDL_qsa_audio.c

@@ -206,7 +206,7 @@ static int QSA_OpenDevice(SDL_AudioDevice *device)
     // Initialize all variables that we clean on shutdown
     device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, (sizeof (struct SDL_PrivateAudioData)));
     if (device->hidden == NULL) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     // Initialize channel transfer parameters to default
@@ -275,7 +275,7 @@ static int QSA_OpenDevice(SDL_AudioDevice *device)
 
     device->hidden->pcm_buf = (Uint8 *) SDL_malloc(device->buffer_size);
     if (device->hidden->pcm_buf == NULL) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     SDL_memset(device->hidden->pcm_buf, device->silence_value, device->buffer_size);
 

+ 3 - 3
src/audio/sndio/SDL_sndioaudio.c

@@ -228,7 +228,7 @@ static int SNDIO_OpenDevice(SDL_AudioDevice *device)
 {
     device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     // !!! FIXME: we really should standardize this on a specific SDL hint.
@@ -243,7 +243,7 @@ static int SNDIO_OpenDevice(SDL_AudioDevice *device)
 
     device->hidden->pfd = SDL_malloc(sizeof(struct pollfd) * SNDIO_sio_nfds(device->hidden->dev));
     if (!device->hidden->pfd) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     struct sio_par par;
@@ -308,7 +308,7 @@ static int SNDIO_OpenDevice(SDL_AudioDevice *device)
     // Allocate mixing buffer
     device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size);
     if (!device->hidden->mixbuf) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size);
 

+ 2 - 3
src/audio/vita/SDL_vitaaudio.c

@@ -62,11 +62,10 @@ static int VITAAUD_OpenDevice(SDL_AudioDevice *device)
     const SDL_AudioFormat *closefmts;
 
     device->hidden = (struct SDL_PrivateAudioData *)
-        SDL_malloc(sizeof(*device->hidden));
+        SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     }
-    SDL_memset(device->hidden, 0, sizeof(*device->hidden));
 
     closefmts = SDL_ClosestAudioFormats(device->spec.format);
     while ((test_format = *(closefmts++)) != 0) {

+ 2 - 2
src/audio/wasapi/SDL_wasapi.c

@@ -104,7 +104,7 @@ int WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, in
 
     ManagementThreadPendingTask *pending = SDL_calloc(1, sizeof(ManagementThreadPendingTask));
     if (!pending) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     pending->fn = task;
@@ -700,7 +700,7 @@ static int WASAPI_OpenDevice(SDL_AudioDevice *device)
     // Initialize all variables that we clean on shutdown
     device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden));
     if (!device->hidden) {
-        return SDL_OutOfMemory();
+        return -1;
     } else if (ActivateWasapiDevice(device) < 0) {
         return -1; // already set error.
     }

+ 6 - 6
src/core/linux/SDL_evdev.c

@@ -170,7 +170,7 @@ int SDL_EVDEV_Init(void)
     if (!_this) {
         _this = (SDL_EVDEV_PrivateData *)SDL_calloc(1, sizeof(*_this));
         if (!_this) {
-            return SDL_OutOfMemory();
+            return -1;
         }
 
 #ifdef SDL_USE_LIBUDEV
@@ -644,7 +644,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
 
     item->touchscreen_data = SDL_calloc(1, sizeof(*item->touchscreen_data));
     if (!item->touchscreen_data) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     ret = ioctl(item->fd, EVIOCGNAME(sizeof(name)), name);
@@ -656,7 +656,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
     item->touchscreen_data->name = SDL_strdup(name);
     if (!item->touchscreen_data->name) {
         SDL_free(item->touchscreen_data);
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     ret = ioctl(item->fd, EVIOCGABS(ABS_MT_SLOT), &abs_info);
@@ -712,7 +712,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
     if (!item->touchscreen_data->slots) {
         SDL_free(item->touchscreen_data->name);
         SDL_free(item->touchscreen_data);
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     for (i = 0; i < item->touchscreen_data->max_slots; i++) {
@@ -883,7 +883,7 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
 
     item = (SDL_evdevlist_item *)SDL_calloc(1, sizeof(SDL_evdevlist_item));
     if (!item) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     item->fd = open(dev_path, O_RDONLY | O_NONBLOCK | O_CLOEXEC);
@@ -896,7 +896,7 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
     if (!item->path) {
         close(item->fd);
         SDL_free(item);
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     item->udev_class = udev_class;

+ 2 - 2
src/core/linux/SDL_udev.c

@@ -112,7 +112,7 @@ int SDL_UDEV_Init(void)
     if (!_this) {
         _this = (SDL_UDEV_PrivateData *)SDL_calloc(1, sizeof(*_this));
         if (!_this) {
-            return SDL_OutOfMemory();
+            return -1;
         }
 
         retval = SDL_UDEV_LoadLibrary();
@@ -518,7 +518,7 @@ int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb)
     SDL_UDEV_CallbackList *item;
     item = (SDL_UDEV_CallbackList *)SDL_calloc(1, sizeof(SDL_UDEV_CallbackList));
     if (!item) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     item->callback = cb;

+ 0 - 2
src/core/windows/SDL_immdevice.c

@@ -149,12 +149,10 @@ static SDL_AudioDevice *SDL_IMMDevice_Add(const SDL_bool iscapture, const char *
         // handle is freed by SDL_IMMDevice_FreeDeviceHandle!
         SDL_IMMDevice_HandleData *handle = SDL_malloc(sizeof(SDL_IMMDevice_HandleData));
         if (!handle) {
-            SDL_OutOfMemory();
             return NULL;
         }
         handle->immdevice_id = SDL_wcsdup(devid);
         if (!handle->immdevice_id) {
-            SDL_OutOfMemory();
             SDL_free(handle);
             return NULL;
         }

+ 0 - 3
src/events/SDL_events.c

@@ -105,7 +105,6 @@ void *SDL_AllocateEventMemory(size_t size)
 {
     void *memory = SDL_malloc(size);
     if (!memory) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
@@ -126,7 +125,6 @@ void *SDL_AllocateEventMemory(size_t size)
         } else {
             SDL_free(memory);
             memory = NULL;
-            SDL_OutOfMemory();
         }
     }
     SDL_UnlockMutex(SDL_event_memory_lock);
@@ -1295,7 +1293,6 @@ int SDL_AddEventWatch(SDL_EventFilter filter, void *userdata)
             watcher->removed = SDL_FALSE;
             ++SDL_event_watchers_count;
         } else {
-            SDL_OutOfMemory();
             result = -1;
         }
     }

+ 1 - 4
src/events/SDL_mouse.c

@@ -489,7 +489,7 @@ int SDL_SetMouseSystemScale(int num_values, const float *values)
 
     v = (float *)SDL_realloc(mouse->system_scale_values, num_values * sizeof(*values));
     if (!v) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     SDL_memcpy(v, values, num_values * sizeof(*values));
 
@@ -1300,9 +1300,6 @@ SDL_Cursor *SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
         cursor = mouse->CreateCursor(surface, hot_x, hot_y);
     } else {
         cursor = SDL_calloc(1, sizeof(*cursor));
-        if (!cursor) {
-            SDL_OutOfMemory();
-        }
     }
     if (cursor) {
         cursor->next = mouse->cursors;

+ 5 - 7
src/events/SDL_touch.c

@@ -57,9 +57,7 @@ SDL_TouchID *SDL_GetTouchDevices(int *count)
 
     const int total = SDL_num_touch;
     SDL_TouchID *retval = (SDL_TouchID *) SDL_malloc(sizeof (SDL_TouchID) * (total + 1));
-    if (!retval) {
-        SDL_OutOfMemory();
-    } else {
+    if (retval) {
         for (int i = 0; i < total; i++) {
             retval[i] = SDL_touchDevices[i]->id;
         }
@@ -169,7 +167,7 @@ int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name
     touchDevices = (SDL_Touch **)SDL_realloc(SDL_touchDevices,
                                              (SDL_num_touch + 1) * sizeof(*touchDevices));
     if (!touchDevices) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     SDL_touchDevices = touchDevices;
@@ -177,7 +175,7 @@ int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name
 
     SDL_touchDevices[index] = (SDL_Touch *)SDL_malloc(sizeof(*SDL_touchDevices[index]));
     if (!SDL_touchDevices[index]) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     /* Added touch to list */
@@ -202,12 +200,12 @@ static int SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float
         SDL_Finger **new_fingers;
         new_fingers = (SDL_Finger **)SDL_realloc(touch->fingers, (touch->max_fingers + 1) * sizeof(*touch->fingers));
         if (!new_fingers) {
-            return SDL_OutOfMemory();
+            return -1;
         }
         touch->fingers = new_fingers;
         touch->fingers[touch->max_fingers] = (SDL_Finger *)SDL_malloc(sizeof(*finger));
         if (!touch->fingers[touch->max_fingers]) {
-            return SDL_OutOfMemory();
+            return -1;
         }
         touch->max_fingers++;
     }

+ 2 - 7
src/file/SDL_rwops.c

@@ -92,7 +92,7 @@ static int SDLCALL windows_file_open(SDL_RWops *context, const char *filename, c
     context->hidden.windowsio.buffer.data =
         (char *)SDL_malloc(READAHEAD_BUFFER_SIZE);
     if (!context->hidden.windowsio.buffer.data) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) && !defined(__WINRT__)
     /* Do not open a dialog box if failure */
@@ -609,9 +609,7 @@ SDL_RWops *SDL_CreateRW(void)
     SDL_RWops *context;
 
     context = (SDL_RWops *)SDL_calloc(1, sizeof(*context));
-    if (!context) {
-        SDL_OutOfMemory();
-    } else {
+    if (context) {
         context->type = SDL_RWOPS_UNKNOWN;
     }
     return context;
@@ -643,12 +641,10 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, SDL_bool freesrc)
         loading_chunks = SDL_TRUE;
     }
     if (size >= SDL_SIZE_MAX) {
-        SDL_OutOfMemory();
         goto done;
     }
     data = (char *)SDL_malloc((size_t)(size + 1));
     if (!data) {
-        SDL_OutOfMemory();
         goto done;
     }
 
@@ -665,7 +661,6 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, SDL_bool freesrc)
                 if (!newdata) {
                     SDL_free(data);
                     data = NULL;
-                    SDL_OutOfMemory();
                     goto done;
                 }
                 data = newdata;

+ 0 - 1
src/file/n3ds/SDL_rwopsromfs.c

@@ -78,7 +78,6 @@ FILE *TryOpenInRomfs(const char *file, const char *mode)
     char *prefixed_filepath = NULL;
 
     if (SDL_asprintf(&prefixed_filepath, "romfs:/%s", file) < 0) {
-        SDL_OutOfMemory();
         return NULL;
     }
 

+ 0 - 1
src/filesystem/android/SDL_sysfilesystem.c

@@ -41,7 +41,6 @@ char *SDL_GetPrefPath(const char *org, const char *app)
         size_t pathlen = SDL_strlen(path) + 2;
         char *fullpath = (char *)SDL_malloc(pathlen);
         if (!fullpath) {
-            SDL_OutOfMemory();
             return NULL;
         }
         SDL_snprintf(fullpath, pathlen, "%s/", path);

+ 3 - 14
src/filesystem/cocoa/SDL_sysfilesystem.m

@@ -52,9 +52,7 @@ char *SDL_GetBasePath(void)
         if (base) {
             const size_t len = SDL_strlen(base) + 2;
             retval = (char *)SDL_malloc(len);
-            if (retval == NULL) {
-                SDL_OutOfMemory();
-            } else {
+            if (retval != NULL) {
                 SDL_snprintf(retval, len, "%s/", base);
             }
         }
@@ -105,9 +103,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
             if (base) {
                 const size_t len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4;
                 retval = (char *)SDL_malloc(len);
-                if (retval == NULL) {
-                    SDL_OutOfMemory();
-                } else {
+                if (retval != NULL) {
                     char *ptr;
                     if (*org) {
                         SDL_snprintf(retval, len, "%s/%s/%s/", base, org, app);
@@ -152,13 +148,7 @@ char *SDL_GetUserFolder(SDL_Folder folder)
                 SDL_SetError("No $HOME environment variable available");
             }
 
-            retval = SDL_strdup(base);
-
-            if (!retval) {
-                SDL_OutOfMemory();
-            }
-
-            return retval;
+            return SDL_strdup(base);
 
         case SDL_FOLDER_DESKTOP:
             dir = NSDesktopDirectory;
@@ -221,7 +211,6 @@ char *SDL_GetUserFolder(SDL_Folder folder)
 
         retval = SDL_strdup(base);
         if (retval == NULL) {
-            SDL_OutOfMemory();
             return NULL;
         }
 

+ 1 - 9
src/filesystem/emscripten/SDL_sysfilesystem.c

@@ -53,7 +53,6 @@ char *SDL_GetPrefPath(const char *org, const char *app)
     len = SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
     retval = (char *)SDL_malloc(len);
     if (!retval) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
@@ -86,7 +85,6 @@ char *SDL_GetPrefPath(const char *org, const char *app)
 char *SDL_GetUserFolder(SDL_Folder folder)
 {
     const char *home = NULL;
-    char *retval;
 
     if (folder != SDL_FOLDER_HOME) {
         SDL_SetError("Emscripten only supports the home folder");
@@ -99,13 +97,7 @@ char *SDL_GetUserFolder(SDL_Folder folder)
         return NULL;
     }
 
-    retval = SDL_strdup(home);
-
-    if (!retval) {
-        SDL_OutOfMemory();
-    }
-
-    return retval;
+    return SDL_strdup(home);
 }
 
 #endif /* SDL_FILESYSTEM_EMSCRIPTEN */

+ 0 - 1
src/filesystem/gdk/SDL_sysfilesystem.cpp

@@ -46,7 +46,6 @@ SDL_GetBasePath(void)
         void *ptr = SDL_realloc(path, buflen * sizeof(CHAR));
         if (!ptr) {
             SDL_free(path);
-            SDL_OutOfMemory();
             return NULL;
         }
 

+ 5 - 16
src/filesystem/haiku/SDL_sysfilesystem.cc

@@ -52,7 +52,6 @@ char *SDL_GetBasePath(void)
     const size_t len = SDL_strlen(str);
     char *retval = (char *) SDL_malloc(len + 2);
     if (!retval) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
@@ -83,9 +82,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
     }
     len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
     char *retval = (char *) SDL_malloc(len);
-    if (!retval) {
-        SDL_OutOfMemory();
-    } else {
+    if (retval) {
         if (*org) {
             SDL_snprintf(retval, len, "%s%s%s/%s/", home, append, org, app);
         } else {
@@ -110,25 +107,17 @@ char *SDL_GetUserFolder(SDL_Folder folder)
 
     switch (folder) {
     case SDL_FOLDER_HOME:
-        retval = SDL_strdup(home);
-
-        if (!retval) {
-            SDL_OutOfMemory();
-        }
-
-        return retval;
+        return SDL_strdup(home);
 
         /* TODO: Is Haiku's desktop folder always ~/Desktop/ ? */
     case SDL_FOLDER_DESKTOP:
         retval = (char *) SDL_malloc(SDL_strlen(home) + 10);
 
-        if (!retval) {
-            SDL_OutOfMemory();
+        if (retval) {
+            SDL_strlcpy(retval, home, SDL_strlen(home) + 10);
+            SDL_strlcat(retval, "/Desktop/", SDL_strlen(home) + 10);
         }
 
-        SDL_strlcpy(retval, home, SDL_strlen(home) + 10);
-        SDL_strlcat(retval, "/Desktop/", SDL_strlen(home) + 10);
-
         return retval;
 
     case SDL_FOLDER_DOCUMENTS:

+ 0 - 1
src/filesystem/n3ds/SDL_sysfilesystem.c

@@ -70,7 +70,6 @@ static char *MakePrefPath(const char *app)
 {
     char *pref_path;
     if (SDL_asprintf(&pref_path, "sdmc:/3ds/%s/", app) < 0) {
-        SDL_OutOfMemory();
         return NULL;
     }
     return pref_path;

+ 0 - 3
src/filesystem/riscos/SDL_sysfilesystem.c

@@ -42,7 +42,6 @@ static char *SDL_unixify_std(const char *ro_path, char *buffer, size_t buf_len,
         buffer = SDL_malloc(buf_len);
 
         if (!buffer) {
-            SDL_OutOfMemory();
             return NULL;
         }
     }
@@ -89,7 +88,6 @@ static char *canonicalisePath(const char *path, const char *pathVar)
     regs.r[5] = 1 - regs.r[5];
     buf = SDL_malloc(regs.r[5]);
     if (!buf) {
-        SDL_OutOfMemory();
         return NULL;
     }
     regs.r[2] = (int)buf;
@@ -174,7 +172,6 @@ char *SDL_GetPrefPath(const char *org, const char *app)
     len = SDL_strlen(canon) + SDL_strlen(org) + SDL_strlen(app) + 4;
     dir = (char *)SDL_malloc(len);
     if (!dir) {
-        SDL_OutOfMemory();
         SDL_free(canon);
         return NULL;
     }

+ 1 - 14
src/filesystem/unix/SDL_sysfilesystem.c

@@ -48,7 +48,6 @@ static char *readSymLink(const char *path)
     while (1) {
         char *ptr = (char *)SDL_realloc(retval, (size_t)len);
         if (!ptr) {
-            SDL_OutOfMemory();
             break;
         }
 
@@ -85,7 +84,6 @@ static char *search_path_for_binary(const char *bin)
 
     envr = SDL_strdup(envr);
     if (!envr) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
@@ -131,7 +129,6 @@ char *SDL_GetBasePath(void)
     if (sysctl(mib, SDL_arraysize(mib), fullpath, &buflen, NULL, 0) != -1) {
         retval = SDL_strdup(fullpath);
         if (!retval) {
-            SDL_OutOfMemory();
             return NULL;
         }
     }
@@ -145,14 +142,12 @@ char *SDL_GetBasePath(void)
         char *exe, *pwddst;
         char *realpathbuf = (char *)SDL_malloc(PATH_MAX + 1);
         if (!realpathbuf) {
-            SDL_OutOfMemory();
             return NULL;
         }
 
         cmdline = SDL_malloc(len);
         if (!cmdline) {
             SDL_free(realpathbuf);
-            SDL_OutOfMemory();
             return NULL;
         }
 
@@ -228,7 +223,6 @@ char *SDL_GetBasePath(void)
         if ((path) && (path[0] == '/')) { /* must be absolute path... */
             retval = SDL_strdup(path);
             if (!retval) {
-                SDL_OutOfMemory();
                 return NULL;
             }
         }
@@ -302,7 +296,6 @@ char *SDL_GetPrefPath(const char *org, const char *app)
     len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
     retval = (char *)SDL_malloc(len);
     if (!retval) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
@@ -541,13 +534,7 @@ char *SDL_GetUserFolder(SDL_Folder folder)
             return NULL;
         }
 
-        retval = SDL_strdup(param);
-
-        if (!retval) {
-            SDL_OutOfMemory();
-        }
-
-        return retval;
+        return SDL_strdup(param);
 
     case SDL_FOLDER_DESKTOP:
         param = "DESKTOP";

+ 0 - 1
src/filesystem/vita/SDL_sysfilesystem.c

@@ -61,7 +61,6 @@ char *SDL_GetPrefPath(const char *org, const char *app)
     len += SDL_strlen(org) + SDL_strlen(app) + 3;
     retval = (char *)SDL_malloc(len);
     if (!retval) {
-        SDL_OutOfMemory();
         return NULL;
     }
 

+ 0 - 3
src/filesystem/windows/SDL_sysfilesystem.c

@@ -53,7 +53,6 @@ char *SDL_GetBasePath(void)
         void *ptr = SDL_realloc(path, buflen * sizeof(WCHAR));
         if (!ptr) {
             SDL_free(path);
-            SDL_OutOfMemory();
             return NULL;
         }
 
@@ -123,14 +122,12 @@ char *SDL_GetPrefPath(const char *org, const char *app)
 
     worg = WIN_UTF8ToStringW(org);
     if (!worg) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
     wapp = WIN_UTF8ToStringW(app);
     if (!wapp) {
         SDL_free(worg);
-        SDL_OutOfMemory();
         return NULL;
     }
 

+ 0 - 3
src/filesystem/winrt/SDL_sysfilesystem.cpp

@@ -131,7 +131,6 @@ SDL_GetBasePath(void)
     destPathLen = SDL_strlen(srcPath) + 2;
     destPath = (char *)SDL_malloc(destPathLen);
     if (!destPath) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
@@ -178,14 +177,12 @@ SDL_GetPrefPath(const char *org, const char *app)
 
     worg = WIN_UTF8ToString(org);
     if (!worg) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
     wapp = WIN_UTF8ToString(app);
     if (!wapp) {
         SDL_free(worg);
-        SDL_OutOfMemory();
         return NULL;
     }
 

+ 0 - 2
src/haptic/SDL_haptic.c

@@ -125,7 +125,6 @@ SDL_Haptic *SDL_HapticOpen(int device_index)
     /* Create the haptic device */
     haptic = (SDL_Haptic *)SDL_malloc(sizeof(*haptic));
     if (!haptic) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
@@ -297,7 +296,6 @@ SDL_Haptic *SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
         /* Create the haptic device */
         haptic = (SDL_Haptic *)SDL_malloc(sizeof(*haptic));
         if (!haptic) {
-            SDL_OutOfMemory();
             SDL_UnlockJoysticks();
             return NULL;
         }

+ 0 - 1
src/haptic/android/SDL_syshaptic.c

@@ -107,7 +107,6 @@ static SDL_hapticlist_item *OpenHaptic(SDL_Haptic *haptic, SDL_hapticlist_item *
     haptic->nplaying = haptic->neffects;
     haptic->effects = (struct haptic_effect *)SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
     if (!haptic->effects) {
-        SDL_OutOfMemory();
         return NULL;
     }
     SDL_memset(haptic->effects, 0, sizeof(struct haptic_effect) * haptic->neffects);

+ 16 - 27
src/haptic/darwin/SDL_syshaptic.c

@@ -473,13 +473,10 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic
     int ret2;
 
     /* Allocate the hwdata */
-    haptic->hwdata = (struct haptic_hwdata *)
-        SDL_malloc(sizeof(*haptic->hwdata));
+    haptic->hwdata = (struct haptic_hwdata *) SDL_calloc(1, sizeof(*haptic->hwdata));
     if (!haptic->hwdata) {
-        SDL_OutOfMemory();
         goto creat_err;
     }
-    SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
 
     /* Open the device */
     ret = FFCreateDevice(service, &haptic->hwdata->device);
@@ -513,7 +510,6 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic
     haptic->effects = (struct haptic_effect *)
         SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
     if (!haptic->effects) {
-        SDL_OutOfMemory();
         goto open_err;
     }
     /* Clear the memory */
@@ -700,7 +696,7 @@ static int SDL_SYS_SetDirection(FFEFFECT *effect, SDL_HapticDirection *dir, int
     /* Has axes. */
     rglDir = SDL_malloc(sizeof(LONG) * naxes);
     if (!rglDir) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     SDL_memset(rglDir, 0, sizeof(LONG) * naxes);
     effect->rglDirection = rglDir;
@@ -771,11 +767,10 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
     dest->dwFlags = FFEFF_OBJECTOFFSETS; /* Seems obligatory. */
 
     /* Envelope. */
-    envelope = SDL_malloc(sizeof(FFENVELOPE));
+    envelope = SDL_calloc(1, sizeof(FFENVELOPE));
     if (!envelope) {
-        return SDL_OutOfMemory();
+        return -1;
     }
-    SDL_memset(envelope, 0, sizeof(FFENVELOPE));
     dest->lpEnvelope = envelope;
     envelope->dwSize = sizeof(FFENVELOPE); /* Always should be this. */
 
@@ -788,7 +783,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
     if (dest->cAxes > 0) {
         axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
         if (!axes) {
-            return SDL_OutOfMemory();
+            return -1;
         }
         axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */
         if (dest->cAxes > 1) {
@@ -804,11 +799,10 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
     switch (src->type) {
     case SDL_HAPTIC_CONSTANT:
         hap_constant = &src->constant;
-        constant = SDL_malloc(sizeof(FFCONSTANTFORCE));
+        constant = SDL_calloc(1, sizeof(FFCONSTANTFORCE));
         if (!constant) {
-            return SDL_OutOfMemory();
+            return -1;
         }
-        SDL_memset(constant, 0, sizeof(FFCONSTANTFORCE));
 
         /* Specifics */
         constant->lMagnitude = CONVERT(hap_constant->level);
@@ -846,11 +840,10 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
     case SDL_HAPTIC_SAWTOOTHUP:
     case SDL_HAPTIC_SAWTOOTHDOWN:
         hap_periodic = &src->periodic;
-        periodic = SDL_malloc(sizeof(FFPERIODIC));
+        periodic = SDL_calloc(1, sizeof(FFPERIODIC));
         if (!periodic) {
-            return SDL_OutOfMemory();
+            return -1;
         }
-        SDL_memset(periodic, 0, sizeof(FFPERIODIC));
 
         /* Specifics */
         periodic->dwMagnitude = CONVERT(SDL_abs(hap_periodic->magnitude));
@@ -891,11 +884,10 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
     case SDL_HAPTIC_FRICTION:
         hap_condition = &src->condition;
         if (dest->cAxes > 0) {
-            condition = SDL_malloc(sizeof(FFCONDITION) * dest->cAxes);
+            condition = SDL_calloc(dest->cAxes, sizeof(FFCONDITION));
             if (!condition) {
-                return SDL_OutOfMemory();
+                return -1;
             }
-            SDL_memset(condition, 0, sizeof(FFCONDITION));
 
             /* Specifics */
             for (i = 0; i < dest->cAxes; i++) {
@@ -934,11 +926,10 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
 
     case SDL_HAPTIC_RAMP:
         hap_ramp = &src->ramp;
-        ramp = SDL_malloc(sizeof(FFRAMPFORCE));
+        ramp = SDL_calloc(1, sizeof(FFRAMPFORCE));
         if (!ramp) {
-            return SDL_OutOfMemory();
+            return -1;
         }
-        SDL_memset(ramp, 0, sizeof(FFRAMPFORCE));
 
         /* Specifics */
         ramp->lStart = CONVERT(hap_ramp->start);
@@ -972,11 +963,10 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
 
     case SDL_HAPTIC_CUSTOM:
         hap_custom = &src->custom;
-        custom = SDL_malloc(sizeof(FFCUSTOMFORCE));
+        custom = SDL_calloc(1, sizeof(FFCUSTOMFORCE));
         if (!custom) {
-            return SDL_OutOfMemory();
+            return -1;
         }
-        SDL_memset(custom, 0, sizeof(FFCUSTOMFORCE));
 
         /* Specifics */
         custom->cChannels = hap_custom->channels;
@@ -1107,9 +1097,8 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
 
     /* Alloc the effect. */
     effect->hweffect = (struct haptic_hweffect *)
-        SDL_malloc(sizeof(struct haptic_hweffect));
+        SDL_calloc(1, sizeof(struct haptic_hweffect));
     if (!effect->hweffect) {
-        SDL_OutOfMemory();
         goto err_hweffect;
     }
 

+ 3 - 6
src/haptic/linux/SDL_syshaptic.c

@@ -375,12 +375,10 @@ static int SDL_SYS_HapticOpenFromFD(SDL_Haptic *haptic, int fd)
 {
     /* Allocate the hwdata */
     haptic->hwdata = (struct haptic_hwdata *)
-        SDL_malloc(sizeof(*haptic->hwdata));
+        SDL_calloc(1, sizeof(*haptic->hwdata));
     if (!haptic->hwdata) {
-        SDL_OutOfMemory();
         goto open_err;
     }
-    SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
 
     /* Set the data. */
     haptic->hwdata->fd = fd;
@@ -397,7 +395,6 @@ static int SDL_SYS_HapticOpenFromFD(SDL_Haptic *haptic, int fd)
     haptic->effects = (struct haptic_effect *)
         SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
     if (!haptic->effects) {
-        SDL_OutOfMemory();
         goto open_err;
     }
     /* Clear the memory */
@@ -903,9 +900,9 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
 
     /* Allocate the hardware effect */
     effect->hweffect = (struct haptic_hweffect *)
-        SDL_malloc(sizeof(struct haptic_hweffect));
+        SDL_calloc(1, sizeof(struct haptic_hweffect));
     if (!effect->hweffect) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     /* Prepare the ff_effect */

+ 17 - 25
src/haptic/windows/SDL_dinputhaptic.c

@@ -167,7 +167,7 @@ int SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance)
 
     item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
     if (!item) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     item->name = WIN_StringToUTF8(pdidInstance->tszProductName);
@@ -286,11 +286,10 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI
     DIPROPDWORD dipdw;
 
     /* Allocate the hwdata */
-    haptic->hwdata = (struct haptic_hwdata *)SDL_malloc(sizeof(*haptic->hwdata));
+    haptic->hwdata = (struct haptic_hwdata *)SDL_calloc(1, sizeof(*haptic->hwdata));
     if (!haptic->hwdata) {
-        return SDL_OutOfMemory();
+        return -1;
     }
-    SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
 
     /* We'll use the device8 from now on. */
     haptic->hwdata->device = device8;
@@ -402,7 +401,6 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI
     haptic->effects = (struct haptic_effect *)
         SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
     if (!haptic->effects) {
-        SDL_OutOfMemory();
         goto acquire_err;
     }
     /* Clear the memory */
@@ -541,7 +539,7 @@ static int SDL_SYS_SetDirection(DIEFFECT *effect, SDL_HapticDirection *dir, int
     /* Has axes. */
     rglDir = SDL_malloc(sizeof(LONG) * naxes);
     if (!rglDir) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     SDL_memset(rglDir, 0, sizeof(LONG) * naxes);
     effect->rglDirection = rglDir;
@@ -613,11 +611,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
     dest->dwFlags = DIEFF_OBJECTOFFSETS; /* Seems obligatory. */
 
     /* Envelope. */
-    envelope = SDL_malloc(sizeof(DIENVELOPE));
+    envelope = SDL_calloc(1, sizeof(DIENVELOPE));
     if (!envelope) {
-        return SDL_OutOfMemory();
+        return -1;
     }
-    SDL_memset(envelope, 0, sizeof(DIENVELOPE));
     dest->lpEnvelope = envelope;
     envelope->dwSize = sizeof(DIENVELOPE); /* Always should be this. */
 
@@ -630,7 +627,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
     if (dest->cAxes > 0) {
         axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
         if (!axes) {
-            return SDL_OutOfMemory();
+            return -1;
         }
         axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */
         if (dest->cAxes > 1) {
@@ -646,11 +643,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
     switch (src->type) {
     case SDL_HAPTIC_CONSTANT:
         hap_constant = &src->constant;
-        constant = SDL_malloc(sizeof(DICONSTANTFORCE));
+        constant = SDL_calloc(1, sizeof(DICONSTANTFORCE));
         if (!constant) {
-            return SDL_OutOfMemory();
+            return -1;
         }
-        SDL_memset(constant, 0, sizeof(DICONSTANTFORCE));
 
         /* Specifics */
         constant->lMagnitude = CONVERT(hap_constant->level);
@@ -688,11 +684,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
     case SDL_HAPTIC_SAWTOOTHUP:
     case SDL_HAPTIC_SAWTOOTHDOWN:
         hap_periodic = &src->periodic;
-        periodic = SDL_malloc(sizeof(DIPERIODIC));
+        periodic = SDL_calloc(1, sizeof(DIPERIODIC));
         if (!periodic) {
-            return SDL_OutOfMemory();
+            return -1;
         }
-        SDL_memset(periodic, 0, sizeof(DIPERIODIC));
 
         /* Specifics */
         periodic->dwMagnitude = CONVERT(SDL_abs(hap_periodic->magnitude));
@@ -732,11 +727,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
     case SDL_HAPTIC_INERTIA:
     case SDL_HAPTIC_FRICTION:
         hap_condition = &src->condition;
-        condition = SDL_malloc(sizeof(DICONDITION) * dest->cAxes);
+        condition = SDL_calloc(dest->cAxes, sizeof(DICONDITION));
         if (!condition) {
-            return SDL_OutOfMemory();
+            return -1;
         }
-        SDL_memset(condition, 0, sizeof(DICONDITION));
 
         /* Specifics */
         for (i = 0; i < (int)dest->cAxes; i++) {
@@ -773,11 +767,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
 
     case SDL_HAPTIC_RAMP:
         hap_ramp = &src->ramp;
-        ramp = SDL_malloc(sizeof(DIRAMPFORCE));
+        ramp = SDL_calloc(1, sizeof(DIRAMPFORCE));
         if (!ramp) {
-            return SDL_OutOfMemory();
+            return -1;
         }
-        SDL_memset(ramp, 0, sizeof(DIRAMPFORCE));
 
         /* Specifics */
         ramp->lStart = CONVERT(hap_ramp->start);
@@ -811,11 +804,10 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
 
     case SDL_HAPTIC_CUSTOM:
         hap_custom = &src->custom;
-        custom = SDL_malloc(sizeof(DICUSTOMFORCE));
+        custom = SDL_calloc(1, sizeof(DICUSTOMFORCE));
         if (!custom) {
-            return SDL_OutOfMemory();
+            return -1;
         }
-        SDL_memset(custom, 0, sizeof(DICUSTOMFORCE));
 
         /* Specifics */
         custom->cChannels = hap_custom->channels;

+ 1 - 4
src/haptic/windows/SDL_windowshaptic.c

@@ -291,13 +291,10 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
     int result;
 
     /* Alloc the effect. */
-    effect->hweffect = (struct haptic_hweffect *)
-        SDL_malloc(sizeof(struct haptic_hweffect));
+    effect->hweffect = (struct haptic_hweffect *) SDL_calloc(1, sizeof(struct haptic_hweffect));
     if (!effect->hweffect) {
-        SDL_OutOfMemory();
         return -1;
     }
-    SDL_zerop(effect->hweffect);
 
     if (haptic->hwdata->bXInputHaptic) {
         result = SDL_XINPUT_HapticNewEffect(haptic, effect, base);

+ 5 - 8
src/haptic/windows/SDL_xinputhaptic.c

@@ -78,13 +78,11 @@ int SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid)
         return -1; /* no force feedback on this device. */
     }
 
-    item = (SDL_hapticlist_item *)SDL_malloc(sizeof(SDL_hapticlist_item));
+    item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
     if (!item) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
-    SDL_zerop(item);
-
     /* !!! FIXME: I'm not bothering to query for a real name right now (can we even?) */
     {
         char buf[64];
@@ -174,19 +172,18 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us
     haptic->effects = (struct haptic_effect *)
         SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
     if (!haptic->effects) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     /* Clear the memory */
     SDL_memset(haptic->effects, 0,
                sizeof(struct haptic_effect) * haptic->neffects);
 
-    haptic->hwdata = (struct haptic_hwdata *)SDL_malloc(sizeof(*haptic->hwdata));
+    haptic->hwdata = (struct haptic_hwdata *)SDL_calloc(1, sizeof(*haptic->hwdata));
     if (!haptic->hwdata) {
         SDL_free(haptic->effects);
         haptic->effects = NULL;
-        return SDL_OutOfMemory();
+        return -1;
     }
-    SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
 
     haptic->hwdata->bXInputHaptic = 1;
     haptic->hwdata->userid = userid;

+ 3 - 24
src/joystick/SDL_gamepad.c

@@ -1434,7 +1434,6 @@ static char *SDL_PrivateGetGamepadGUIDFromMappingString(const char *pMapping)
     if (pFirstComma) {
         char *pchGUID = SDL_malloc(pFirstComma - pMapping + 1);
         if (!pchGUID) {
-            SDL_OutOfMemory();
             return NULL;
         }
         SDL_memcpy(pchGUID, pMapping, pFirstComma - pMapping);
@@ -1483,7 +1482,6 @@ static char *SDL_PrivateGetGamepadNameFromMappingString(const char *pMapping)
 
     pchName = SDL_malloc(pSecondComma - pFirstComma);
     if (!pchName) {
-        SDL_OutOfMemory();
         return NULL;
     }
     SDL_memcpy(pchName, pFirstComma + 1, pSecondComma - pFirstComma);
@@ -1620,7 +1618,6 @@ static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, co
             PopMappingChangeTracking();
             SDL_free(pchName);
             SDL_free(pchMapping);
-            SDL_OutOfMemory();
             return NULL;
         }
         /* Clear the CRC, we've already added it to the mapping */
@@ -2032,7 +2029,6 @@ static char *CreateMappingString(GamepadMapping_t *mapping, SDL_JoystickGUID gui
 
     pMappingString = SDL_malloc(needed);
     if (!pMappingString) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
@@ -2082,7 +2078,6 @@ char **SDL_GetGamepadMappings(int *count)
     mappings = (char **) SDL_calloc(num_mappings + 1, sizeof (char *));
     if (!mappings) {
         failed = SDL_TRUE;
-        SDL_OutOfMemory();
     } else {
         size_t i = 0;
         for (GamepadMapping_t *mapping = s_pSupportedGamepads; mapping; mapping = mapping->next) {
@@ -2107,9 +2102,7 @@ char **SDL_GetGamepadMappings(int *count)
 
     if (!failed) {
         retval = (char **) SDL_malloc(final_allocation);
-        if (!retval) {
-            SDL_OutOfMemory();
-        } else {
+        if (retval) {
             final_allocation -= (sizeof (char *) * num_mappings + 1);
             char *strptr = (char *) (retval + (num_mappings + 1));
             for (int i = 0; i < num_mappings; i++) {
@@ -2431,19 +2424,10 @@ char *SDL_GetGamepadInstanceMapping(SDL_JoystickID instance_id)
     {
         GamepadMapping_t *mapping = SDL_PrivateGetGamepadMapping(instance_id);
         if (mapping) {
-            SDL_JoystickGUID guid;
             char pchGUID[33];
-            size_t needed;
-            guid = SDL_GetJoystickInstanceGUID(instance_id);
+            const SDL_JoystickGUID guid = SDL_GetJoystickInstanceGUID(instance_id);
             SDL_GetJoystickGUIDString(guid, pchGUID, sizeof(pchGUID));
-            /* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */
-            needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1;
-            retval = (char *)SDL_malloc(needed);
-            if (retval) {
-                (void)SDL_snprintf(retval, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping);
-            } else {
-                SDL_OutOfMemory();
-            }
+            SDL_asprintf(&retval, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping);
         }
     }
     SDL_UnlockJoysticks();
@@ -2595,7 +2579,6 @@ SDL_Gamepad *SDL_OpenGamepad(SDL_JoystickID instance_id)
     /* Create and initialize the gamepad */
     gamepad = (SDL_Gamepad *)SDL_calloc(1, sizeof(*gamepad));
     if (!gamepad) {
-        SDL_OutOfMemory();
         SDL_UnlockJoysticks();
         return NULL;
     }
@@ -2611,7 +2594,6 @@ SDL_Gamepad *SDL_OpenGamepad(SDL_JoystickID instance_id)
     if (gamepad->joystick->naxes) {
         gamepad->last_match_axis = (SDL_GamepadBinding **)SDL_calloc(gamepad->joystick->naxes, sizeof(*gamepad->last_match_axis));
         if (!gamepad->last_match_axis) {
-            SDL_OutOfMemory();
             SDL_CloseJoystick(gamepad->joystick);
             SDL_free(gamepad);
             SDL_UnlockJoysticks();
@@ -2621,7 +2603,6 @@ SDL_Gamepad *SDL_OpenGamepad(SDL_JoystickID instance_id)
     if (gamepad->joystick->nhats) {
         gamepad->last_hat_mask = (Uint8 *)SDL_calloc(gamepad->joystick->nhats, sizeof(*gamepad->last_hat_mask));
         if (!gamepad->last_hat_mask) {
-            SDL_OutOfMemory();
             SDL_CloseJoystick(gamepad->joystick);
             SDL_free(gamepad->last_match_axis);
             SDL_free(gamepad);
@@ -3442,8 +3423,6 @@ SDL_GamepadBinding **SDL_GetGamepadBindings(SDL_Gamepad *gamepad, int *count)
             if (count) {
                 *count = gamepad->num_bindings;
             }
-        } else {
-            SDL_OutOfMemory();
         }
     }
     SDL_UnlockJoysticks();

+ 0 - 5
src/joystick/SDL_joystick.c

@@ -270,7 +270,6 @@ static SDL_bool SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID
     if (player_index >= SDL_joystick_player_count) {
         SDL_JoystickID *new_players = (SDL_JoystickID *)SDL_realloc(SDL_joystick_players, (player_index + 1) * sizeof(*SDL_joystick_players));
         if (!new_players) {
-            SDL_OutOfMemory();
             return SDL_FALSE;
         }
 
@@ -403,8 +402,6 @@ SDL_JoystickID *SDL_GetJoysticks(int *count)
             if (count) {
                 *count = 0;
             }
-
-            SDL_OutOfMemory();
         }
     }
     SDL_UnlockJoysticks();
@@ -755,7 +752,6 @@ SDL_Joystick *SDL_OpenJoystick(SDL_JoystickID instance_id)
     /* Create and initialize the joystick */
     joystick = (SDL_Joystick *)SDL_calloc(sizeof(*joystick), 1);
     if (!joystick) {
-        SDL_OutOfMemory();
         SDL_UnlockJoysticks();
         return NULL;
     }
@@ -798,7 +794,6 @@ SDL_Joystick *SDL_OpenJoystick(SDL_JoystickID instance_id)
         joystick->buttons = (Uint8 *)SDL_calloc(joystick->nbuttons, sizeof(Uint8));
     }
     if (((joystick->naxes > 0) && !joystick->axes) || ((joystick->nhats > 0) && !joystick->hats) || ((joystick->nbuttons > 0) && !joystick->buttons)) {
-        SDL_OutOfMemory();
         SDL_CloseJoystick(joystick);
         SDL_UnlockJoysticks();
         return NULL;

+ 0 - 2
src/joystick/apple/SDL_mfijoystick.m

@@ -1165,7 +1165,6 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
             int button_count = 0;
 
             if (buttons == NULL) {
-                SDL_OutOfMemory();
                 return;
             }
 
@@ -1222,7 +1221,6 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
             int button_count = 0;
 
             if (buttons == NULL) {
-                SDL_OutOfMemory();
                 return;
             }
 

+ 1 - 2
src/joystick/bsd/SDL_bsdjoystick.c

@@ -270,7 +270,6 @@ CreateHwData(const char *path)
         SDL_calloc(1, sizeof(struct joystick_hwdata));
     if (!hw) {
         close(fd);
-        SDL_OutOfMemory();
         return NULL;
     }
     hw->fd = fd;
@@ -794,7 +793,7 @@ static int report_alloc(struct report *r, struct report_desc *rd, int repind)
                             r->size);
 #endif
         if (!r->buf) {
-            return SDL_OutOfMemory();
+            return -1;
         }
     } else {
         r->buf = NULL;

+ 1 - 2
src/joystick/darwin/SDL_iokitjoystick.c

@@ -529,7 +529,6 @@ static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender
 
     device = (recDevice *)SDL_calloc(1, sizeof(recDevice));
     if (!device) {
-        SDL_OutOfMemory();
         return;
     }
 
@@ -834,7 +833,7 @@ static int DARWIN_JoystickInitRumble(recDevice *device, Sint16 magnitude)
     /* Create the effect */
     device->ffeffect = CreateRumbleEffectData(magnitude);
     if (!device->ffeffect) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     result = FFDeviceCreateEffect(device->ffdevice, kFFEffectType_Sine_ID,

+ 5 - 9
src/joystick/haiku/SDL_haikujoystick.cc

@@ -129,12 +129,10 @@ extern "C"
 
         /* Create the joystick data structure */
         joystick->instance_id = device_index;
-        joystick->hwdata = (struct joystick_hwdata *)
-            SDL_malloc(sizeof(*joystick->hwdata));
+        joystick->hwdata = (struct joystick_hwdata *) SDL_calloc(1, sizeof(*joystick->hwdata));
         if (joystick->hwdata == NULL) {
-            return SDL_OutOfMemory();
+            return -1;
         }
-        SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
         stick = new BJoystick;
         joystick->hwdata->stick = stick;
 
@@ -152,13 +150,11 @@ extern "C"
         joystick->naxes = stick->CountAxes();
         joystick->nhats = stick->CountHats();
 
-        joystick->hwdata->new_axes = (int16 *)
-            SDL_malloc(joystick->naxes * sizeof(int16));
-        joystick->hwdata->new_hats = (uint8 *)
-            SDL_malloc(joystick->nhats * sizeof(uint8));
+        joystick->hwdata->new_axes = (int16 *) SDL_calloc(joystick->naxes, sizeof(int16));
+        joystick->hwdata->new_hats = (uint8 *) SDL_calloc(joystick->nhats, sizeof(uint8));
         if (!joystick->hwdata->new_hats || !joystick->hwdata->new_axes) {
             HAIKU_JoystickClose(joystick);
-            return SDL_OutOfMemory();
+            return -1;
         }
 
         /* We're done! */

+ 0 - 1
src/joystick/hidapi/SDL_hidapi_gamecube.c

@@ -115,7 +115,6 @@ static SDL_bool HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device)
 
     ctx = (SDL_DriverGameCube_Context *)SDL_calloc(1, sizeof(*ctx));
     if (!ctx) {
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
     device->context = ctx;

+ 0 - 1
src/joystick/hidapi/SDL_hidapi_luna.c

@@ -73,7 +73,6 @@ static SDL_bool HIDAPI_DriverLuna_InitDevice(SDL_HIDAPI_Device *device)
 
     ctx = (SDL_DriverLuna_Context *)SDL_calloc(1, sizeof(*ctx));
     if (!ctx) {
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
     device->context = ctx;

+ 0 - 2
src/joystick/hidapi/SDL_hidapi_ps3.c

@@ -135,7 +135,6 @@ static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device)
 
     ctx = (SDL_DriverPS3_Context *)SDL_calloc(1, sizeof(*ctx));
     if (!ctx) {
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
     ctx->device = device;
@@ -605,7 +604,6 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_InitDevice(SDL_HIDAPI_Device *device)
 
     ctx = (SDL_DriverPS3_Context *)SDL_calloc(1, sizeof(*ctx));
     if (!ctx) {
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
     ctx->device = device;

+ 0 - 1
src/joystick/hidapi/SDL_hidapi_ps4.c

@@ -277,7 +277,6 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device)
 
     ctx = (SDL_DriverPS4_Context *)SDL_calloc(1, sizeof(*ctx));
     if (!ctx) {
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
     ctx->device = device;

+ 0 - 1
src/joystick/hidapi/SDL_hidapi_ps5.c

@@ -376,7 +376,6 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
 
     ctx = (SDL_DriverPS5_Context *)SDL_calloc(1, sizeof(*ctx));
     if (!ctx) {
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
     ctx->device = device;

+ 1 - 1
src/joystick/hidapi/SDL_hidapi_rumble.c

@@ -216,7 +216,7 @@ int SDL_HIDAPI_SendRumbleWithCallbackAndUnlock(SDL_HIDAPI_Device *device, const
     request = (SDL_HIDAPI_RumbleRequest *)SDL_calloc(1, sizeof(*request));
     if (!request) {
         SDL_HIDAPI_UnlockRumble();
-        return SDL_OutOfMemory();
+        return -1;
     }
     request->device = device;
     SDL_memcpy(request->data, data, size);

+ 0 - 1
src/joystick/hidapi/SDL_hidapi_shield.c

@@ -115,7 +115,6 @@ static SDL_bool HIDAPI_DriverShield_InitDevice(SDL_HIDAPI_Device *device)
 
     ctx = (SDL_DriverShield_Context *)SDL_calloc(1, sizeof(*ctx));
     if (!ctx) {
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
     device->context = ctx;

+ 0 - 1
src/joystick/hidapi/SDL_hidapi_stadia.c

@@ -70,7 +70,6 @@ static SDL_bool HIDAPI_DriverStadia_InitDevice(SDL_HIDAPI_Device *device)
 
     ctx = (SDL_DriverStadia_Context *)SDL_calloc(1, sizeof(*ctx));
     if (!ctx) {
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
     device->context = ctx;

+ 0 - 1
src/joystick/hidapi/SDL_hidapi_steam.c

@@ -974,7 +974,6 @@ static SDL_bool HIDAPI_DriverSteam_InitDevice(SDL_HIDAPI_Device *device)
 
     ctx = (SDL_DriverSteam_Context *)SDL_calloc(1, sizeof(*ctx));
     if (!ctx) {
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
     device->context = ctx;

+ 0 - 1
src/joystick/hidapi/SDL_hidapi_switch.c

@@ -1246,7 +1246,6 @@ static SDL_bool HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device)
 
     ctx = (SDL_DriverSwitch_Context *)SDL_calloc(1, sizeof(*ctx));
     if (!ctx) {
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
     ctx->device = device;

+ 0 - 1
src/joystick/hidapi/SDL_hidapi_wii.c

@@ -719,7 +719,6 @@ static SDL_bool HIDAPI_DriverWii_InitDevice(SDL_HIDAPI_Device *device)
 
     ctx = (SDL_DriverWii_Context *)SDL_calloc(1, sizeof(*ctx));
     if (!ctx) {
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
     ctx->device = device;

+ 0 - 1
src/joystick/hidapi/SDL_hidapi_xbox360.c

@@ -140,7 +140,6 @@ static SDL_bool HIDAPI_DriverXbox360_InitDevice(SDL_HIDAPI_Device *device)
 
     ctx = (SDL_DriverXbox360_Context *)SDL_calloc(1, sizeof(*ctx));
     if (!ctx) {
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
     ctx->device = device;

+ 0 - 1
src/joystick/hidapi/SDL_hidapi_xbox360w.c

@@ -132,7 +132,6 @@ static SDL_bool HIDAPI_DriverXbox360W_InitDevice(SDL_HIDAPI_Device *device)
 
     ctx = (SDL_DriverXbox360W_Context *)SDL_calloc(1, sizeof(*ctx));
     if (!ctx) {
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
     ctx->device = device;

+ 0 - 1
src/joystick/hidapi/SDL_hidapi_xboxone.c

@@ -360,7 +360,6 @@ static SDL_bool HIDAPI_DriverXboxOne_InitDevice(SDL_HIDAPI_Device *device)
 
     ctx = (SDL_DriverXboxOne_Context *)SDL_calloc(1, sizeof(*ctx));
     if (!ctx) {
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
     ctx->device = device;

+ 1 - 1
src/joystick/hidapi/SDL_hidapijoystick.c

@@ -1435,7 +1435,7 @@ static int HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index)
 
     hwdata = (struct joystick_hwdata *)SDL_calloc(1, sizeof(*hwdata));
     if (!hwdata) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     hwdata->device = device;
 

+ 2 - 4
src/joystick/linux/SDL_sysjoystick.c

@@ -1381,7 +1381,7 @@ static int PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item,
             if (fd_sensor >= 0) {
                 close(fd_sensor);
             }
-            return SDL_OutOfMemory();
+            return -1;
         }
 
         /* Set the joystick to non-blocking read mode */
@@ -1471,7 +1471,7 @@ static int LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index)
     joystick->hwdata = (struct joystick_hwdata *)
         SDL_calloc(1, sizeof(*joystick->hwdata));
     if (!joystick->hwdata) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     item_sensor = GetSensor(item);
@@ -2147,7 +2147,6 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap
        a fake SDL_Joystick object to do so. */
     joystick = (SDL_Joystick *)SDL_calloc(sizeof(*joystick), 1);
     if (!joystick) {
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
     joystick->magic = &SDL_joystick_magic;
@@ -2157,7 +2156,6 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap
         SDL_calloc(1, sizeof(*joystick->hwdata));
     if (!joystick->hwdata) {
         SDL_free(joystick);
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
 

+ 4 - 4
src/joystick/virtual/SDL_virtualjoystick.c

@@ -125,7 +125,7 @@ SDL_JoystickID SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *des
     hwdata = SDL_calloc(1, sizeof(joystick_hwdata));
     if (!hwdata) {
         VIRTUAL_FreeHWData(hwdata);
-        return SDL_OutOfMemory();
+        return -1;
     }
     SDL_memcpy(&hwdata->desc, desc, sizeof(*desc));
 
@@ -210,7 +210,7 @@ SDL_JoystickID SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *des
         hwdata->axes = SDL_calloc(hwdata->desc.naxes, sizeof(Sint16));
         if (!hwdata->axes) {
             VIRTUAL_FreeHWData(hwdata);
-            return SDL_OutOfMemory();
+            return -1;
         }
 
         /* Trigger axes are at minimum value at rest */
@@ -225,14 +225,14 @@ SDL_JoystickID SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *des
         hwdata->buttons = SDL_calloc(hwdata->desc.nbuttons, sizeof(Uint8));
         if (!hwdata->buttons) {
             VIRTUAL_FreeHWData(hwdata);
-            return SDL_OutOfMemory();
+            return -1;
         }
     }
     if (hwdata->desc.nhats > 0) {
         hwdata->hats = SDL_calloc(hwdata->desc.nhats, sizeof(Uint8));
         if (!hwdata->hats) {
             VIRTUAL_FreeHWData(hwdata);
-            return SDL_OutOfMemory();
+            return -1;
         }
     }
 

+ 1 - 1
src/joystick/windows/SDL_dinputjoystick.c

@@ -878,7 +878,7 @@ static int SDL_DINPUT_JoystickInitRumble(SDL_Joystick *joystick, Sint16 magnitud
     /* Create the effect */
     joystick->hwdata->ffeffect = CreateRumbleEffectData(magnitude);
     if (!joystick->hwdata->ffeffect) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     result = IDirectInputDevice8_CreateEffect(joystick->hwdata->InputDevice, &GUID_Sine,

+ 7 - 7
src/joystick/windows/SDL_rawinputjoystick.c

@@ -618,12 +618,12 @@ static int RAWINPUT_UpdateWindowsGamingInput()
                             WindowsGamingInputGamepadState **new_per_gamepad;
                             gamepad_state = SDL_calloc(1, sizeof(*gamepad_state));
                             if (!gamepad_state) {
-                                return SDL_OutOfMemory();
+                                return -1;
                             }
                             new_per_gamepad = SDL_realloc(wgi_state.per_gamepad, sizeof(wgi_state.per_gamepad[0]) * (wgi_state.per_gamepad_count + 1));
                             if (!new_per_gamepad) {
                                 SDL_free(gamepad_state);
-                                return SDL_OutOfMemory();
+                                return -1;
                             }
                             wgi_state.per_gamepad = new_per_gamepad;
                             wgi_state.per_gamepad_count++;
@@ -1227,7 +1227,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
 
     ctx = (RAWINPUT_DeviceContext *)SDL_calloc(1, sizeof(RAWINPUT_DeviceContext));
     if (!ctx) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     joystick->hwdata = ctx;
 
@@ -1259,7 +1259,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
     ctx->data = (HIDP_DATA *)SDL_malloc(ctx->max_data_length * sizeof(*ctx->data));
     if (!ctx->data) {
         RAWINPUT_JoystickClose(joystick);
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     if (SDL_HidP_GetCaps(ctx->preparsed_data, &caps) != HIDP_STATUS_SUCCESS) {
@@ -1304,7 +1304,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
         ctx->button_indices = (USHORT *)SDL_malloc(joystick->nbuttons * sizeof(*ctx->button_indices));
         if (!ctx->button_indices) {
             RAWINPUT_JoystickClose(joystick);
-            return SDL_OutOfMemory();
+            return -1;
         }
 
         for (i = 0; i < caps.NumberInputButtonCaps; ++i) {
@@ -1357,7 +1357,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
         ctx->axis_indices = (USHORT *)SDL_malloc(joystick->naxes * sizeof(*ctx->axis_indices));
         if (!ctx->axis_indices) {
             RAWINPUT_JoystickClose(joystick);
-            return SDL_OutOfMemory();
+            return -1;
         }
 
         for (i = 0; i < caps.NumberInputValueCaps; ++i) {
@@ -1390,7 +1390,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
         ctx->hat_indices = (USHORT *)SDL_malloc(joystick->nhats * sizeof(*ctx->hat_indices));
         if (!ctx->hat_indices) {
             RAWINPUT_JoystickClose(joystick);
-            return SDL_OutOfMemory();
+            return -1;
         }
 
         for (i = 0; i < caps.NumberInputValueCaps; ++i) {

+ 1 - 2
src/joystick/windows/SDL_windows_gaming_input.c

@@ -128,7 +128,6 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product)
 
     raw_devices = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * raw_device_count);
     if (!raw_devices) {
-        SDL_OutOfMemory();
         return SDL_FALSE;
     }
 
@@ -720,7 +719,7 @@ static int WGI_JoystickOpen(SDL_Joystick *joystick, int device_index)
 
     hwdata = (struct joystick_hwdata *)SDL_calloc(1, sizeof(*hwdata));
     if (!hwdata) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     joystick->hwdata = hwdata;
 

+ 2 - 4
src/joystick/windows/SDL_windowsjoystick.c

@@ -670,12 +670,10 @@ static int WINDOWS_JoystickOpen(SDL_Joystick *joystick, int device_index)
 
     /* allocate memory for system specific hardware data */
     joystick->instance_id = device->nInstanceID;
-    joystick->hwdata =
-        (struct joystick_hwdata *)SDL_malloc(sizeof(struct joystick_hwdata));
+    joystick->hwdata = (struct joystick_hwdata *)SDL_calloc(1, sizeof(struct joystick_hwdata));
     if (!joystick->hwdata) {
-        return SDL_OutOfMemory();
+        return -1;
     }
-    SDL_zerop(joystick->hwdata);
     joystick->hwdata->guid = device->guid;
 
     if (device->bXInputDevice) {

+ 0 - 1
src/locale/SDL_locale.c

@@ -48,7 +48,6 @@ static SDL_Locale *build_locales_from_csv_string(char *csv)
 
     loc = retval = (SDL_Locale *)SDL_calloc(1, alloclen);
     if (!retval) {
-        SDL_OutOfMemory();
         return NULL; /* oh well */
     }
     ptr = (char *)(retval + num_locales);

+ 1 - 1
src/locale/unix/SDL_syslocale.c

@@ -72,7 +72,7 @@ int SDL_SYS_GetPreferredLocales(char *buf, size_t buflen)
     SDL_assert(buflen > 0);
     tmp = SDL_small_alloc(char, buflen, &isstack);
     if (!tmp) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     *tmp = '\0';

+ 1 - 1
src/locale/windows/SDL_syslocale.c

@@ -66,7 +66,7 @@ static int SDL_SYS_GetPreferredLocales_vista(char *buf, size_t buflen)
 
     wbuf = SDL_small_alloc(WCHAR, wbuflen, &isstack);
     if (!wbuf) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     if (!pGetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &numlangs, wbuf, &wbuflen)) {

+ 1 - 1
src/misc/windows/SDL_sysurl.c

@@ -47,7 +47,7 @@ int SDL_SYS_OpenURL(const char *url)
     wurl = WIN_UTF8ToStringW(url);
     if (!wurl) {
         WIN_CoUninitialize();
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     /* Success returns value greater than 32. Less is an error. */

+ 1 - 1
src/misc/winrt/SDL_sysurl.cpp

@@ -27,7 +27,7 @@ int SDL_SYS_OpenURL(const char *url)
 {
     WCHAR *wurl = WIN_UTF8ToStringW(url);
     if (!wurl) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     auto strurl = ref new Platform::String(wurl);
     SDL_free(wurl);

+ 8 - 11
src/render/SDL_render.c

@@ -293,7 +293,6 @@ void *SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes,
         ptr = SDL_realloc(renderer->vertex_data, newsize);
 
         if (!ptr) {
-            SDL_OutOfMemory();
             return NULL;
         }
         renderer->vertex_data = ptr;
@@ -321,7 +320,6 @@ static SDL_RenderCommand *AllocateRenderCommand(SDL_Renderer *renderer)
     } else {
         retval = SDL_calloc(1, sizeof(*retval));
         if (!retval) {
-            SDL_OutOfMemory();
             return NULL;
         }
     }
@@ -1158,7 +1156,6 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert
     }
     texture = (SDL_Texture *)SDL_calloc(1, sizeof(*texture));
     if (!texture) {
-        SDL_OutOfMemory();
         return NULL;
     }
     texture->magic = &SDL_texture_magic;
@@ -1566,7 +1563,7 @@ static int SDL_UpdateTextureYUV(SDL_Texture *texture, const SDL_Rect *rect,
         if (alloclen > 0) {
             void *temp_pixels = SDL_malloc(alloclen);
             if (!temp_pixels) {
-                return SDL_OutOfMemory();
+                return -1;
             }
             SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
                                 rect->w, rect->h, temp_pixels, temp_pitch);
@@ -1606,7 +1603,7 @@ static int SDL_UpdateTextureNative(SDL_Texture *texture, const SDL_Rect *rect,
         if (alloclen > 0) {
             void *temp_pixels = SDL_malloc(alloclen);
             if (!temp_pixels) {
-                return SDL_OutOfMemory();
+                return -1;
             }
             SDL_ConvertPixels(rect->w, rect->h,
                               texture->format, pixels, pitch,
@@ -1699,7 +1696,7 @@ static int SDL_UpdateTextureYUVPlanar(SDL_Texture *texture, const SDL_Rect *rect
         if (alloclen > 0) {
             void *temp_pixels = SDL_malloc(alloclen);
             if (!temp_pixels) {
-                return SDL_OutOfMemory();
+                return -1;
             }
             SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
                                 rect->w, rect->h, temp_pixels, temp_pitch);
@@ -1749,7 +1746,7 @@ static int SDL_UpdateTextureNVPlanar(SDL_Texture *texture, const SDL_Rect *rect,
         if (alloclen > 0) {
             void *temp_pixels = SDL_malloc(alloclen);
             if (!temp_pixels) {
-                return SDL_OutOfMemory();
+                return -1;
             }
             SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format,
                                 rect->w, rect->h, temp_pixels, temp_pitch);
@@ -2694,7 +2691,7 @@ static int RenderPointsWithRects(SDL_Renderer *renderer, const SDL_FPoint *fpoin
 
     frects = SDL_small_alloc(SDL_FRect, count, &isstack);
     if (!frects) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     for (i = 0; i < count; ++i) {
@@ -2814,7 +2811,7 @@ static int RenderLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x2, i
 
     points = SDL_small_alloc(SDL_FPoint, numpixels, &isstack);
     if (!points) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     for (i = 0; i < numpixels; ++i) {
         points[i].x = (float)x;
@@ -2857,7 +2854,7 @@ static int RenderLinesWithRectsF(SDL_Renderer *renderer,
 
     frects = SDL_small_alloc(SDL_FRect, count - 1, &isstack);
     if (!frects) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     for (i = 0; i < count - 1; ++i) {
@@ -3160,7 +3157,7 @@ int SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int coun
 
     frects = SDL_small_alloc(SDL_FRect, count, &isstack);
     if (!frects) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     for (i = 0; i < count; ++i) {
         frects[i].x = rects[i].x * renderer->view->scale.x;

+ 0 - 3
src/render/SDL_yuv_sw.c

@@ -47,7 +47,6 @@ SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
 
     swdata = (SDL_SW_YUVTexture *)SDL_calloc(1, sizeof(*swdata));
     if (!swdata) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
@@ -59,13 +58,11 @@ SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
         size_t dst_size;
         if (SDL_CalculateYUVSize(format, w, h, &dst_size, NULL) < 0) {
             SDL_SW_DestroyYUVTexture(swdata);
-            SDL_OutOfMemory();
             return NULL;
         }
         swdata->pixels = (Uint8 *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), dst_size);
         if (!swdata->pixels) {
             SDL_SW_DestroyYUVTexture(swdata);
-            SDL_OutOfMemory();
             return NULL;
         }
     }

+ 2 - 4
src/render/direct3d/SDL_render_d3d.c

@@ -525,7 +525,7 @@ static int D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
 
     texturedata = (D3D_TextureData *)SDL_calloc(1, sizeof(*texturedata));
     if (!texturedata) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     texturedata->scaleMode = (texture->scaleMode == SDL_SCALEMODE_NEAREST) ? D3DTEXF_POINT : D3DTEXF_LINEAR;
 
@@ -661,7 +661,7 @@ static int D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
             texturedata->pitch = texture->w;
             texturedata->pixels = (Uint8 *)SDL_malloc((texture->h * texturedata->pitch * 3) / 2);
             if (!texturedata->pixels) {
-                return SDL_OutOfMemory();
+                return -1;
             }
         }
         *pixels =
@@ -1562,7 +1562,6 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, SDL_PropertiesID create_pro
 
     renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
     if (!renderer) {
-        SDL_OutOfMemory();
         return NULL;
     }
     renderer->magic = &SDL_renderer_magic;
@@ -1570,7 +1569,6 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, SDL_PropertiesID create_pro
     data = (D3D_RenderData *)SDL_calloc(1, sizeof(*data));
     if (!data) {
         SDL_free(renderer);
-        SDL_OutOfMemory();
         return NULL;
     }
 

+ 1 - 5
src/render/direct3d11/SDL_render_d3d11.c

@@ -399,7 +399,6 @@ static ID3D11BlendState *D3D11_CreateBlendState(SDL_Renderer *renderer, SDL_Blen
     blendModes = (D3D11_BlendMode *)SDL_realloc(data->blendModes, (data->blendModesCount + 1) * sizeof(*blendModes));
     if (!blendModes) {
         SAFE_RELEASE(blendState);
-        SDL_OutOfMemory();
         return NULL;
     }
     blendModes[data->blendModesCount].blendMode = blendMode;
@@ -1095,7 +1094,6 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
 
     textureData = (D3D11_TextureData *)SDL_calloc(1, sizeof(*textureData));
     if (!textureData) {
-        SDL_OutOfMemory();
         return -1;
     }
     textureData->scaleMode = (texture->scaleMode == SDL_SCALEMODE_NEAREST) ? D3D11_FILTER_MIN_MAG_MIP_POINT : D3D11_FILTER_MIN_MAG_MIP_LINEAR;
@@ -1554,7 +1552,7 @@ static int D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
             textureData->pitch = texture->w;
             textureData->pixels = (Uint8 *)SDL_malloc((texture->h * textureData->pitch * 3) / 2);
             if (!textureData->pixels) {
-                return SDL_OutOfMemory();
+                return -1;
             }
         }
         textureData->locked_rect = *rect;
@@ -2436,7 +2434,6 @@ SDL_Renderer *D3D11_CreateRenderer(SDL_Window *window, SDL_PropertiesID create_p
 
     renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
     if (!renderer) {
-        SDL_OutOfMemory();
         return NULL;
     }
     renderer->magic = &SDL_renderer_magic;
@@ -2444,7 +2441,6 @@ SDL_Renderer *D3D11_CreateRenderer(SDL_Window *window, SDL_PropertiesID create_p
     data = (D3D11_RenderData *)SDL_calloc(1, sizeof(*data));
     if (!data) {
         SDL_free(renderer);
-        SDL_OutOfMemory();
         return NULL;
     }
 

+ 1 - 5
src/render/direct3d12/SDL_render_d3d12.c

@@ -644,7 +644,6 @@ static D3D12_PipelineState *D3D12_CreatePipelineState(SDL_Renderer *renderer,
     pipelineStates = (D3D12_PipelineState *)SDL_realloc(data->pipelineStates, (data->pipelineStateCount + 1) * sizeof(*pipelineStates));
     if (!pipelineStates) {
         SAFE_RELEASE(pipelineState);
-        SDL_OutOfMemory();
         return NULL;
     }
 
@@ -1460,7 +1459,6 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
 
     textureData = (D3D12_TextureData *)SDL_calloc(1, sizeof(*textureData));
     if (!textureData) {
-        SDL_OutOfMemory();
         return -1;
     }
     textureData->scaleMode = (texture->scaleMode == SDL_SCALEMODE_NEAREST) ? D3D12_FILTER_MIN_MAG_MIP_POINT : D3D12_FILTER_MIN_MAG_MIP_LINEAR;
@@ -1910,7 +1908,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture,
             textureData->pitch = texture->w;
             textureData->pixels = (Uint8 *)SDL_malloc((texture->h * textureData->pitch * 3) / 2);
             if (!textureData->pixels) {
-                return SDL_OutOfMemory();
+                return -1;
             }
         }
         textureData->lockedRect = *rect;
@@ -2987,7 +2985,6 @@ SDL_Renderer *D3D12_CreateRenderer(SDL_Window *window, SDL_PropertiesID create_p
 
     renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
     if (!renderer) {
-        SDL_OutOfMemory();
         return NULL;
     }
     renderer->magic = &SDL_renderer_magic;
@@ -2995,7 +2992,6 @@ SDL_Renderer *D3D12_CreateRenderer(SDL_Window *window, SDL_PropertiesID create_p
     data = (D3D12_RenderData *)SDL_calloc(1, sizeof(*data));
     if (!data) {
         SDL_free(renderer);
-        SDL_OutOfMemory();
         return NULL;
     }
 

+ 1 - 4
src/render/metal/SDL_render_metal.m

@@ -339,7 +339,6 @@ static id<MTLRenderPipelineState> MakePipelineState(METAL_RenderData *data, META
         return (__bridge id<MTLRenderPipelineState>)pipeline.pipe;
     } else {
         CFBridgingRelease(pipeline.pipe);
-        SDL_OutOfMemory();
         return NULL;
     }
 }
@@ -401,7 +400,6 @@ static METAL_ShaderPipelines *ChooseShaderPipelines(METAL_RenderData *data, MTLP
     allpipelines = SDL_realloc(allpipelines, (count + 1) * sizeof(METAL_ShaderPipelines));
 
     if (allpipelines == NULL) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
@@ -1507,7 +1505,7 @@ static int METAL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
         temp_pitch = rect->w * 4UL;
         temp_pixels = SDL_malloc(temp_pitch * rect->h);
         if (!temp_pixels) {
-            return SDL_OutOfMemory();
+            return -1;
         }
 
         [mtltexture getBytes:temp_pixels bytesPerRow:temp_pitch fromRegion:mtlregion mipmapLevel:0];
@@ -1747,7 +1745,6 @@ static SDL_Renderer *METAL_CreateRenderer(SDL_Window *window, SDL_PropertiesID c
 
         renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
         if (!renderer) {
-            SDL_OutOfMemory();
             return NULL;
         }
 

+ 3 - 5
src/render/opengl/SDL_render_gl.c

@@ -468,7 +468,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr
 
     data = (GL_TextureData *)SDL_calloc(1, sizeof(*data));
     if (!data) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
@@ -488,7 +488,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Pr
         data->pixels = SDL_calloc(1, size);
         if (!data->pixels) {
             SDL_free(data);
-            return SDL_OutOfMemory();
+            return -1;
         }
     }
 
@@ -1483,7 +1483,7 @@ static int GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
     temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
     temp_pixels = SDL_malloc((size_t)rect->h * temp_pitch);
     if (!temp_pixels) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     SDL_GetCurrentRenderOutputSize(renderer, &w, &h);
@@ -1794,14 +1794,12 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, SDL_PropertiesID crea
 
     renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
     if (!renderer) {
-        SDL_OutOfMemory();
         goto error;
     }
 
     data = (GL_RenderData *)SDL_calloc(1, sizeof(*data));
     if (!data) {
         SDL_free(renderer);
-        SDL_OutOfMemory();
         goto error;
     }
 

+ 4 - 7
src/render/opengles2/SDL_render_gles2.c

@@ -421,7 +421,6 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin
     /* Create a program cache entry */
     entry = (GLES2_ProgramCacheEntry *)SDL_calloc(1, sizeof(GLES2_ProgramCacheEntry));
     if (!entry) {
-        SDL_OutOfMemory();
         return NULL;
     }
     entry->vertex_shader = vertex;
@@ -1466,7 +1465,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
     /* Allocate a texture struct */
     data = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData));
     if (!data) {
-        return SDL_OutOfMemory();
+        return -1;
     }
     data->texture = 0;
 #ifdef GL_TEXTURE_EXTERNAL_OES
@@ -1501,7 +1500,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL
         data->pixel_data = SDL_calloc(1, size);
         if (!data->pixel_data) {
             SDL_free(data);
-            return SDL_OutOfMemory();
+            return -1;
         }
     }
 
@@ -1623,7 +1622,7 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff
     if ((size_t)pitch != src_pitch) {
         blob = (Uint8 *)SDL_malloc(src_pitch * height);
         if (!blob) {
-            return SDL_OutOfMemory();
+            return -1;
         }
         src = blob;
         for (y = 0; y < height; ++y) {
@@ -1946,7 +1945,7 @@ static int GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
 
     temp_pixels = SDL_malloc(buflen);
     if (!temp_pixels) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     SDL_GetCurrentRenderOutputSize(renderer, &w, &h);
@@ -2109,14 +2108,12 @@ static SDL_Renderer *GLES2_CreateRenderer(SDL_Window *window, SDL_PropertiesID c
     /* Create the renderer struct */
     renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(SDL_Renderer));
     if (!renderer) {
-        SDL_OutOfMemory();
         goto error;
     }
 
     data = (GLES2_RenderData *)SDL_calloc(1, sizeof(GLES2_RenderData));
     if (!data) {
         SDL_free(renderer);
-        SDL_OutOfMemory();
         goto error;
     }
     renderer->info = GLES2_RenderDriver.info;

+ 2 - 4
src/render/ps2/SDL_render_ps2.c

@@ -111,7 +111,7 @@ static int PS2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
     GSTEXTURE *ps2_tex = (GSTEXTURE *)SDL_calloc(1, sizeof(GSTEXTURE));
 
     if (!ps2_tex) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     ps2_tex->Width = texture->w;
@@ -121,7 +121,7 @@ static int PS2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
 
     if (!ps2_tex->Mem) {
         SDL_free(ps2_tex);
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     texture->driverdata = ps2_tex;
@@ -595,14 +595,12 @@ static SDL_Renderer *PS2_CreateRenderer(SDL_Window *window, SDL_PropertiesID cre
 
     renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
     if (!renderer) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
     data = (PS2_RenderData *)SDL_calloc(1, sizeof(*data));
     if (!data) {
         PS2_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
         return NULL;
     }
 

+ 5 - 7
src/render/psp/SDL_render_psp.c

@@ -286,7 +286,7 @@ static int TextureSwizzle(PSP_TextureData *psp_texture, void *dst)
     }
 
     if (!data) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     for (j = 0; j < height; j++, blockaddress += 16) {
@@ -348,7 +348,7 @@ static int TextureUnswizzle(PSP_TextureData *psp_texture, void *dst)
     }
 
     if (!data) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     ydst = (unsigned char *)data;
@@ -392,7 +392,7 @@ static int TextureSpillToSram(PSP_RenderData *data, PSP_TextureData *psp_texture
         // Texture was swizzled in vram, just copy to system memory
         void *sdata = SDL_malloc(psp_texture->size);
         if (!sdata) {
-            return SDL_OutOfMemory();
+            return -1;
         }
 
         SDL_memcpy(sdata, psp_texture->data, psp_texture->size);
@@ -484,7 +484,7 @@ static int PSP_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
     PSP_TextureData *psp_texture = (PSP_TextureData *)SDL_calloc(1, sizeof(*psp_texture));
 
     if (!psp_texture) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     psp_texture->swizzled = SDL_FALSE;
@@ -527,7 +527,7 @@ static int PSP_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_P
 
     if (!psp_texture->data) {
         SDL_free(psp_texture);
-        return SDL_OutOfMemory();
+        return -1;
     }
     texture->driverdata = psp_texture;
 
@@ -1304,14 +1304,12 @@ SDL_Renderer *PSP_CreateRenderer(SDL_Window *window, SDL_PropertiesID create_pro
 
     renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
     if (!renderer) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
     data = (PSP_RenderData *)SDL_calloc(1, sizeof(*data));
     if (!data) {
         PSP_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
         return NULL;
     }
 

+ 0 - 2
src/render/software/SDL_render_sw.c

@@ -1111,14 +1111,12 @@ SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface)
 
     renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
     if (!renderer) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
     data = (SW_RenderData *)SDL_calloc(1, sizeof(*data));
     if (!data) {
         SW_DestroyRenderer(renderer);
-        SDL_OutOfMemory();
         return NULL;
     }
     data->surface = surface;

+ 2 - 4
src/render/vitagxm/SDL_render_vita_gxm.c

@@ -218,14 +218,12 @@ SDL_Renderer *VITA_GXM_CreateRenderer(SDL_Window *window, SDL_PropertiesID creat
 
     renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer));
     if (!renderer) {
-        SDL_OutOfMemory();
         return NULL;
     }
 
     data = (VITA_GXM_RenderData *)SDL_calloc(1, sizeof(VITA_GXM_RenderData));
     if (!data) {
         SDL_free(renderer);
-        SDL_OutOfMemory();
         return NULL;
     }
 
@@ -298,7 +296,7 @@ static int VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
     VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)SDL_calloc(1, sizeof(VITA_GXM_TextureData));
 
     if (!vita_texture) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     vita_texture->tex = create_gxm_texture(
@@ -1111,7 +1109,7 @@ static int VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rec
 
     temp_pixels = SDL_malloc(buflen);
     if (!temp_pixels) {
-        return SDL_OutOfMemory();
+        return -1;
     }
 
     SDL_GetCurrentRenderOutputSize(renderer, &w, &h);

+ 0 - 3
src/sensor/SDL_sensor.c

@@ -208,8 +208,6 @@ SDL_SensorID *SDL_GetSensors(int *count)
             if (count) {
                 *count = 0;
             }
-
-            SDL_OutOfMemory();
         }
     }
     SDL_UnlockSensors();
@@ -330,7 +328,6 @@ SDL_Sensor *SDL_OpenSensor(SDL_SensorID instance_id)
     /* Create and initialize the sensor */
     sensor = (SDL_Sensor *)SDL_calloc(sizeof(*sensor), 1);
     if (!sensor) {
-        SDL_OutOfMemory();
         SDL_UnlockSensors();
         return NULL;
     }

Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov