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.
This commit is contained in:
Ryan C. Gordon
2023-11-30 00:14:27 -05:00
parent 70b65d4170
commit 447b508a77
197 changed files with 313 additions and 742 deletions
-3
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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;
-2
View File
@@ -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;
}
-3
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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;
-1
View File
@@ -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;
}
@@ -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
View File
@@ -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;
}
@@ -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 */
-1
View File
@@ -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
View File
@@ -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:
-1
View File
@@ -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;
@@ -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
View File
@@ -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";
-1
View File
@@ -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;
}
@@ -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;
}
@@ -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;
}
-2
View File
@@ -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;
}
-1
View File
@@ -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);

Some files were not shown because too many files have changed in this diff Show More