do not use osd_malloc/osd_free in non-OSD code (nw)

This commit is contained in:
Oliver Stöneberg 2014-03-24 21:56:16 +00:00
parent b52f668f13
commit 7a135e058a
3 changed files with 20 additions and 20 deletions

View File

@ -87,24 +87,24 @@ text_buffer *text_buffer_alloc(UINT32 bytes, UINT32 lines)
text_buffer *text; text_buffer *text;
/* allocate memory for the text buffer object */ /* allocate memory for the text buffer object */
text = (text_buffer *)osd_malloc(sizeof(*text)); text = (text_buffer *)global_alloc(sizeof(*text));
if (!text) if (!text)
return NULL; return NULL;
/* allocate memory for the buffer itself */ /* allocate memory for the buffer itself */
text->buffer = (char *)osd_malloc_array(bytes); text->buffer = (char *)global_alloc_array(bytes);
if (!text->buffer) if (!text->buffer)
{ {
osd_free(text); global_free(text);
return NULL; return NULL;
} }
/* allocate memory for the lines array */ /* allocate memory for the lines array */
text->lineoffs = (INT32 *)osd_malloc_array(lines * sizeof(text->lineoffs[0])); text->lineoffs = (INT32 *)global_alloc_array(lines * sizeof(text->lineoffs[0]));
if (!text->lineoffs) if (!text->lineoffs)
{ {
osd_free(text->buffer); global_free_array(text->buffer);
osd_free(text); global_free(text);
return NULL; return NULL;
} }
@ -125,10 +125,10 @@ text_buffer *text_buffer_alloc(UINT32 bytes, UINT32 lines)
void text_buffer_free(text_buffer *text) void text_buffer_free(text_buffer *text)
{ {
if (text->lineoffs) if (text->lineoffs)
osd_free(text->lineoffs); global_free_array(text->lineoffs);
if (text->buffer) if (text->buffer)
osd_free(text->buffer); global_free_array(text->buffer);
osd_free(text); global_free(text);
} }

View File

@ -16,7 +16,7 @@ wav_file *wav_open(const char *filename, int sample_rate, int channels)
UINT16 align, temp16; UINT16 align, temp16;
/* allocate memory for the wav struct */ /* allocate memory for the wav struct */
wav = (wav_file *) osd_malloc(sizeof(wav_file)); wav = (wav_file *) global_alloc(sizeof(wav_file));
if (!wav) if (!wav)
return NULL; return NULL;
@ -24,7 +24,7 @@ wav_file *wav_open(const char *filename, int sample_rate, int channels)
wav->file = fopen(filename, "wb"); wav->file = fopen(filename, "wb");
if (!wav->file) if (!wav->file)
{ {
osd_free(wav); global_free(wav);
return NULL; return NULL;
} }
@ -106,7 +106,7 @@ void wav_close(wav_file *wav)
fwrite(&temp32, 1, 4, wav->file); fwrite(&temp32, 1, 4, wav->file);
fclose(wav->file); fclose(wav->file);
osd_free(wav); global_free(wav);
} }
@ -128,7 +128,7 @@ void wav_add_data_32(wav_file *wav, INT32 *data, int samples, int shift)
if (!wav) return; if (!wav) return;
/* allocate temp memory */ /* allocate temp memory */
temp = (INT16 *)osd_malloc_array(samples * sizeof(temp[0])); temp = (INT16 *)global_alloc_array(samples * sizeof(temp[0]));
if (!temp) if (!temp)
return; return;
@ -144,7 +144,7 @@ void wav_add_data_32(wav_file *wav, INT32 *data, int samples, int shift)
fflush(wav->file); fflush(wav->file);
/* free memory */ /* free memory */
osd_free(temp); global_free_array(temp);
} }
@ -156,7 +156,7 @@ void wav_add_data_16lr(wav_file *wav, INT16 *left, INT16 *right, int samples)
if (!wav) return; if (!wav) return;
/* allocate temp memory */ /* allocate temp memory */
temp = (INT16 *)osd_malloc_array(samples * 2 * sizeof(temp[0])); temp = (INT16 *)global_alloc_array(samples * 2 * sizeof(temp[0]));
if (!temp) if (!temp)
return; return;
@ -169,7 +169,7 @@ void wav_add_data_16lr(wav_file *wav, INT16 *left, INT16 *right, int samples)
fflush(wav->file); fflush(wav->file);
/* free memory */ /* free memory */
osd_free(temp); global_free_array(temp);
} }
@ -181,7 +181,7 @@ void wav_add_data_32lr(wav_file *wav, INT32 *left, INT32 *right, int samples, in
if (!wav) return; if (!wav) return;
/* allocate temp memory */ /* allocate temp memory */
temp = (INT16 *)osd_malloc_array(samples * 2 * sizeof(temp[0])); temp = (INT16 *)global_alloc_array(samples * 2 * sizeof(temp[0]));
if (!temp) if (!temp)
return; return;
@ -198,5 +198,5 @@ void wav_add_data_32lr(wav_file *wav, INT32 *left, INT32 *right, int samples, in
fflush(wav->file); fflush(wav->file);
/* free memory */ /* free memory */
osd_free(temp); global_free_array(temp);
} }

View File

@ -176,7 +176,7 @@ FLOPPY_CONSTRUCT( apridisk_construct )
} }
else if (compression == APR_COMPRESSED) else if (compression == APR_COMPRESSED)
{ {
UINT8 *buffer = (UINT8 *)osd_malloc(data_size * sizeof(UINT8)); UINT8 *buffer = (UINT8 *)global_alloc(data_size * sizeof(UINT8));
UINT16 length; UINT16 length;
UINT8 value; UINT8 value;
@ -185,7 +185,7 @@ FLOPPY_CONSTRUCT( apridisk_construct )
length = pick_integer_le(buffer, 0, 2); length = pick_integer_le(buffer, 0, 2);
value = pick_integer_le(buffer, 2, 1); value = pick_integer_le(buffer, 2, 1);
osd_free(buffer); global_free(buffer);
/* not sure if this is possible */ /* not sure if this is possible */
if (length != 512) { if (length != 512) {