Fix the memory leaks with the strconv.c function by

using osd_malloc() instead.  Fixed other memory leaks as well.  [Oliver Stoneberg]
This commit is contained in:
Scott Stone 2010-04-23 17:10:03 +00:00
parent 2d638c2691
commit ca0f74f334
22 changed files with 96 additions and 92 deletions

View File

@ -489,7 +489,7 @@ void debug_view_end_update(debug_view *view)
if (size > view->viewdata_size)
{
view->viewdata_size = size;
global_free(view->viewdata);
auto_free(view->machine, view->viewdata);
view->viewdata = auto_alloc_array(view->machine, debug_view_char, view->viewdata_size);
}

View File

@ -482,14 +482,14 @@ static int render_font_load_cached_bdf(render_font *font, const char *filename)
global_free(data);
/* close the file */
global_free(cachedname);
osd_free(cachedname);
mame_fclose(file);
return result;
error:
/* close the file */
if (cachedname != NULL)
global_free(cachedname);
osd_free(cachedname);
if (data != NULL)
global_free(data);
mame_fclose(file);

View File

@ -1246,7 +1246,7 @@ void ui_paste(running_machine *machine)
inputx_post_utf8(machine, text);
/* free the string */
free(text);
osd_free(text);
}
}

View File

@ -247,7 +247,7 @@ void pool_clear(object_pool *pool)
/*-------------------------------------------------
pool_free - frees a memory pool and all
pool_free_lib - frees a memory pool and all
contained memory blocks
-------------------------------------------------*/

View File

@ -822,7 +822,7 @@ void osd_break_into_debugger(const char *message);
Return value:
the returned string needs to be free()-ed!
the returned string needs to be osd_free()-ed!
-----------------------------------------------------------------------------*/
char *osd_get_clipboard_text(void);
@ -858,7 +858,7 @@ osd_directory_entry *osd_stat(const char *path);
Parameters:
path - the path in question
dst - pointer to receive new path; the returned string needs to be free()-ed!
dst - pointer to receive new path; the returned string needs to be osd_free()-ed!
Return value:

View File

@ -60,7 +60,7 @@ extern "C" int _tmain(int argc, TCHAR **argv)
/* free arguments */
for (i = 0; i < argc; i++)
free(utf8_argv[i]);
osd_free(utf8_argv[i]);
free(utf8_argv);
#ifdef MALLOC_DEBUG

View File

@ -277,7 +277,7 @@ char *osd_get_clipboard_text(void)
length = CFDataGetLength (data_ref);
range = CFRangeMake (0,length);
result = (char *)malloc (length+1);
result = (char *)osd_malloc (length+1);
if (result != NULL)
{
CFDataGetBytes (data_ref, range, (unsigned char *)result);
@ -373,7 +373,7 @@ file_error osd_get_full_path(char **dst, const char *path)
}
else
{
*dst = (char *)malloc(strlen(path_buffer)+strlen(path)+3);
*dst = (char *)osd_malloc(strlen(path_buffer)+strlen(path)+3);
// if it's already a full path, just pass it through
if (path[0] == '/')

View File

@ -293,7 +293,7 @@ file_error osd_get_full_path(char **dst, const char *path)
}
else
{
*dst = (char *)malloc(strlen(path_buffer)+strlen(path)+3);
*dst = (char *)osd_malloc(strlen(path_buffer)+strlen(path)+3);
// if it's already a full path, just pass it through
if (path[0] == '/')

View File

@ -377,7 +377,7 @@ CHAR *astring_from_utf8(const char *utf8string)
// convert UTF-16 to "ANSI code page" string
char_count = WideCharToMultiByte(CP_ACP, 0, wstring, -1, NULL, 0, NULL, NULL);
result = (CHAR *)malloc(char_count * sizeof(*result));
result = (CHAR *)osd_malloc(char_count * sizeof(*result));
if (result != NULL)
WideCharToMultiByte(CP_ACP, 0, wstring, -1, result, char_count, NULL, NULL);
@ -395,7 +395,7 @@ WCHAR *wstring_from_utf8(const char *utf8string)
// convert MAME string (UTF-8) to UTF-16
char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0);
result = (WCHAR *)malloc(char_count * sizeof(*result));
result = (WCHAR *)osd_malloc(char_count * sizeof(*result));
if (result != NULL)
MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, result, char_count);
@ -449,7 +449,7 @@ osd_directory_entry *osd_stat(const char *path)
done:
if (t_path)
free(t_path);
osd_free(t_path);
return result;
}
@ -549,7 +549,7 @@ file_error osd_get_full_path(char **dst, const char *path)
done:
if (t_path != NULL)
free(t_path);
osd_free(t_path);
return err;
}

View File

@ -38,7 +38,7 @@ char *utf8_from_astring(const CHAR *astring)
// convert UTF-16 to MAME string (UTF-8)
char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL);
result = (CHAR *)malloc(char_count * sizeof(*result));
result = (CHAR *)osd_malloc(char_count * sizeof(*result));
if (result != NULL)
WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL);
@ -56,7 +56,7 @@ char *utf8_from_wstring(const WCHAR *wstring)
// convert UTF-16 to MAME string (UTF-8)
char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL);
result = (char *)malloc(char_count * sizeof(*result));
result = (char *)osd_malloc(char_count * sizeof(*result));
if (result != NULL)
WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL);

View File

@ -20,11 +20,13 @@
#ifdef SDLMAME_WIN32
CHAR *astring_from_utf8(const char *s) ATTR_MALLOC;
char *utf8_from_astring(const CHAR *s) ATTR_MALLOC;
// the result of these functions has to be released with osd_free()
WCHAR *wstring_from_utf8(const char *s) ATTR_MALLOC;
char *utf8_from_wstring(const WCHAR *s) ATTR_MALLOC;
CHAR *astring_from_utf8(const char *s);
char *utf8_from_astring(const CHAR *s);
WCHAR *wstring_from_utf8(const char *s);
char *utf8_from_wstring(const WCHAR *s);
#ifdef UNICODE
#define tstring_from_utf8 wstring_from_utf8

View File

@ -192,7 +192,7 @@ void sdlvideo_monitor_refresh(sdl_monitor_info *monitor)
monitor->center_height = monitor->monitor_height = info.rcMonitor.bottom - info.rcMonitor.top;
char *temp = utf8_from_wstring(info.szDevice);
strcpy(monitor->monitor_device, temp);
global_free(temp);
osd_free(temp);
#elif defined(SDLMAME_MACOSX) // Mac OS X Core Imaging version
CGDirectDisplayID primary;
CGRect dbounds;
@ -421,7 +421,7 @@ static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect,
monitor->monitor_height = info.rcMonitor.bottom - info.rcMonitor.top;
char *temp = utf8_from_wstring(info.szDevice);
strcpy(monitor->monitor_device, temp);
global_free(temp);
osd_free(temp);
// guess the aspect ratio assuming square pixels
monitor->aspect = (float)(info.rcMonitor.right - info.rcMonitor.left) / (float)(info.rcMonitor.bottom - info.rcMonitor.top);

View File

@ -430,7 +430,7 @@ void debugwin_init_windows(void)
t_face = tstring_from_utf8(options_get_string(mame_options(), WINOPTION_DEBUGGER_FONT));
debug_font = CreateFont(-MulDiv(size, GetDeviceCaps(temp_dc, LOGPIXELSY), 72), 0, 0, 0, FW_MEDIUM, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, t_face);
global_free(t_face);
osd_free(t_face);
// fall back to Lucida Console 8
if (debug_font == NULL)
@ -1574,7 +1574,7 @@ static LRESULT CALLBACK debugwin_edit_proc(HWND wnd, UINT message, WPARAM wparam
if (utf8_buffer != NULL)
{
(*info->process_string)(info, utf8_buffer);
global_free(utf8_buffer);
osd_free(utf8_buffer);
}
}
break;
@ -1777,7 +1777,7 @@ static void memory_create_window(running_machine *machine)
{
TCHAR *t_name = tstring_from_utf8(subview->name);
int item = SendMessage(info->otherwnd[0], CB_ADDSTRING, 0, (LPARAM)t_name);
global_free(t_name);
osd_free(t_name);
if (cursel == -1 && subview->space != NULL && subview->space->cpu == curcpu)
cursel = item;
}
@ -2086,7 +2086,7 @@ static void disasm_create_window(running_machine *machine)
{
TCHAR *t_name = tstring_from_utf8(subview->name);
int item = SendMessage(info->otherwnd[0], CB_ADDSTRING, 0, (LPARAM)t_name);
global_free(t_name);
osd_free(t_name);
if (cursel == 0 && subview->space->cpu == curcpu)
cursel = item;
}

View File

@ -1200,7 +1200,7 @@ static int config_adapter_mode(win_window_info *window)
if (utf8_device != NULL)
{
mame_printf_error("Device %s currently in an unsupported mode\n", utf8_device);
global_free(utf8_device);
osd_free(utf8_device);
}
return 1;
}
@ -1228,7 +1228,7 @@ static int config_adapter_mode(win_window_info *window)
if (utf8_device != NULL)
{
mame_printf_error("Proposed video mode not supported on device %s\n", utf8_device);
global_free(utf8_device);
osd_free(utf8_device);
}
return 1;
}

View File

@ -276,7 +276,7 @@ static void dinput_exit(running_machine *machine);
static HRESULT dinput_set_dword_property(LPDIRECTINPUTDEVICE device, REFGUID property_guid, DWORD object, DWORD how, DWORD value);
static device_info *dinput_device_create(running_machine *machine, device_info **devlist_head_ptr, LPCDIDEVICEINSTANCE instance, LPCDIDATAFORMAT format1, LPCDIDATAFORMAT format2, DWORD cooperative_level);
static void dinput_device_release(device_info *devinfo);
static const char *dinput_device_item_name(device_info *devinfo, int offset, const TCHAR *defstring, const TCHAR *suffix);
static char *dinput_device_item_name(device_info *devinfo, int offset, const TCHAR *defstring, const TCHAR *suffix);
static HRESULT dinput_device_poll(device_info *devinfo);
static BOOL CALLBACK dinput_keyboard_enum(LPCDIDEVICEINSTANCE instance, LPVOID ref);
static void dinput_keyboard_poll(device_info *devinfo);
@ -853,7 +853,7 @@ static void generic_device_free(device_info *devinfo)
// free the copy of the name if present
if (devinfo->name != NULL)
global_free((void *)devinfo->name);
osd_free((void *)devinfo->name);
devinfo->name = NULL;
// and now free the info
@ -968,17 +968,17 @@ static void win32_init(running_machine *machine)
// populate the axes
for (axisnum = 0; axisnum < 2; axisnum++)
{
const char *name = utf8_from_tstring(default_axis_name[axisnum]);
char *name = utf8_from_tstring(default_axis_name[axisnum]);
input_device_item_add(devinfo->device, name, &devinfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state);
global_free(name);
osd_free(name);
}
// populate the buttons
for (butnum = 0; butnum < 2; butnum++)
{
const char *name = utf8_from_tstring(default_button_name(butnum));
char *name = utf8_from_tstring(default_button_name(butnum));
input_device_item_add(devinfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state);
global_free(name);
osd_free(name);
}
}
}
@ -1264,7 +1264,7 @@ static void dinput_device_release(device_info *devinfo)
// dinput_device_item_name
//============================================================
static const char *dinput_device_item_name(device_info *devinfo, int offset, const TCHAR *defstring, const TCHAR *suffix)
static char *dinput_device_item_name(device_info *devinfo, int offset, const TCHAR *defstring, const TCHAR *suffix)
{
DIDEVICEOBJECTINSTANCE instance = { 0 };
const TCHAR *namestring = instance.tszName;
@ -1350,7 +1350,7 @@ static BOOL CALLBACK dinput_keyboard_enum(LPCDIDEVICEINSTANCE instance, LPVOID r
{
input_item_id itemid = keyboard_map_scancode_to_itemid(keynum);
TCHAR defname[20];
const char *name;
char *name;
// generate/fetch the name
_sntprintf(defname, ARRAY_LENGTH(defname), TEXT("Scan%03d"), keynum);
@ -1358,7 +1358,7 @@ static BOOL CALLBACK dinput_keyboard_enum(LPCDIDEVICEINSTANCE instance, LPVOID r
// add the item to the device
input_device_item_add(devinfo->device, name, &devinfo->keyboard.state[keynum], itemid, generic_button_get_state);
global_free(name);
osd_free(name);
}
exit:
@ -1430,21 +1430,21 @@ static BOOL CALLBACK dinput_mouse_enum(LPCDIDEVICEINSTANCE instance, LPVOID ref)
// populate the axes
for (axisnum = 0; axisnum < devinfo->dinput.caps.dwAxes; axisnum++)
{
const char *name = dinput_device_item_name(devinfo, offsetof(DIMOUSESTATE, lX) + axisnum * sizeof(LONG), default_axis_name[axisnum], NULL);
char *name = dinput_device_item_name(devinfo, offsetof(DIMOUSESTATE, lX) + axisnum * sizeof(LONG), default_axis_name[axisnum], NULL);
// add to the mouse device and optionally to the gun device as well
input_device_item_add(devinfo->device, name, &devinfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state);
if (guninfo != NULL && axisnum < 2)
input_device_item_add(guninfo->device, name, &guninfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state);
global_free(name);
osd_free(name);
}
// populate the buttons
for (butnum = 0; butnum < devinfo->dinput.caps.dwButtons; butnum++)
{
FPTR offset = (FPTR)(&((DIMOUSESTATE *)NULL)->rgbButtons[butnum]);
const char *name = dinput_device_item_name(devinfo, offset, default_button_name(butnum), NULL);
char *name = dinput_device_item_name(devinfo, offset, default_button_name(butnum), NULL);
// add to the mouse device and optionally to the gun device as well
// note that the gun device points to the mouse buttons rather than its own
@ -1452,7 +1452,7 @@ static BOOL CALLBACK dinput_mouse_enum(LPCDIDEVICEINSTANCE instance, LPVOID ref)
if (guninfo != NULL)
input_device_item_add(guninfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state);
global_free(name);
osd_free(name);
}
exit:
@ -1528,7 +1528,7 @@ static BOOL CALLBACK dinput_joystick_enum(LPCDIDEVICEINSTANCE instance, LPVOID r
for (axisnum = axiscount = 0; axiscount < devinfo->dinput.caps.dwAxes && axisnum < 8; axisnum++)
{
DIPROPRANGE dipr;
const char *name;
char *name;
// fetch the range of this axis
dipr.diph.dwSize = sizeof(dipr);
@ -1544,7 +1544,7 @@ static BOOL CALLBACK dinput_joystick_enum(LPCDIDEVICEINSTANCE instance, LPVOID r
// populate the item description as well
name = dinput_device_item_name(devinfo, offsetof(DIJOYSTATE2, lX) + axisnum * sizeof(LONG), default_axis_name[axisnum], NULL);
input_device_item_add(devinfo->device, name, &devinfo->joystick.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state);
global_free(name);
osd_free(name);
axiscount++;
}
@ -1552,36 +1552,36 @@ static BOOL CALLBACK dinput_joystick_enum(LPCDIDEVICEINSTANCE instance, LPVOID r
// populate the POVs
for (povnum = 0; povnum < devinfo->dinput.caps.dwPOVs; povnum++)
{
const char *name;
char *name;
// left
name = dinput_device_item_name(devinfo, offsetof(DIJOYSTATE2, rgdwPOV) + povnum * sizeof(DWORD), default_pov_name(povnum), TEXT("L"));
input_device_item_add(devinfo->device, name, (void *)(FPTR)(povnum * 4 + POVDIR_LEFT), ITEM_ID_OTHER_SWITCH, dinput_joystick_pov_get_state);
global_free(name);
osd_free(name);
// right
name = dinput_device_item_name(devinfo, offsetof(DIJOYSTATE2, rgdwPOV) + povnum * sizeof(DWORD), default_pov_name(povnum), TEXT("R"));
input_device_item_add(devinfo->device, name, (void *)(FPTR)(povnum * 4 + POVDIR_RIGHT), ITEM_ID_OTHER_SWITCH, dinput_joystick_pov_get_state);
global_free(name);
osd_free(name);
// up
name = dinput_device_item_name(devinfo, offsetof(DIJOYSTATE2, rgdwPOV) + povnum * sizeof(DWORD), default_pov_name(povnum), TEXT("U"));
input_device_item_add(devinfo->device, name, (void *)(FPTR)(povnum * 4 + POVDIR_UP), ITEM_ID_OTHER_SWITCH, dinput_joystick_pov_get_state);
global_free(name);
osd_free(name);
// down
name = dinput_device_item_name(devinfo, offsetof(DIJOYSTATE2, rgdwPOV) + povnum * sizeof(DWORD), default_pov_name(povnum), TEXT("D"));
input_device_item_add(devinfo->device, name, (void *)(FPTR)(povnum * 4 + POVDIR_DOWN), ITEM_ID_OTHER_SWITCH, dinput_joystick_pov_get_state);
global_free(name);
osd_free(name);
}
// populate the buttons
for (butnum = 0; butnum < devinfo->dinput.caps.dwButtons; butnum++)
{
FPTR offset = (FPTR)(&((DIJOYSTATE2 *)NULL)->rgbButtons[butnum]);
const char *name = dinput_device_item_name(devinfo, offset, default_button_name(butnum), NULL);
char *name = dinput_device_item_name(devinfo, offset, default_button_name(butnum), NULL);
input_device_item_add(devinfo->device, name, &devinfo->joystick.state.rgbButtons[butnum], (butnum < 16) ? (input_item_id)(ITEM_ID_BUTTON1 + butnum) : ITEM_ID_OTHER_SWITCH, generic_button_get_state);
global_free(name);
osd_free(name);
}
exit:
@ -1967,7 +1967,7 @@ static void rawinput_keyboard_enum(running_machine *machine, PRAWINPUTDEVICELIST
{
input_item_id itemid = keyboard_map_scancode_to_itemid(keynum);
TCHAR keyname[100];
const char *name;
char *name;
// generate the name
if (GetKeyNameText(((keynum & 0x7f) << 16) | ((keynum & 0x80) << 17), keyname, ARRAY_LENGTH(keyname)) == 0)
@ -1976,7 +1976,7 @@ static void rawinput_keyboard_enum(running_machine *machine, PRAWINPUTDEVICELIST
// add the item to the device
input_device_item_add(devinfo->device, name, &devinfo->keyboard.state[keynum], itemid, generic_button_get_state);
global_free(name);
osd_free(name);
}
}
@ -2043,27 +2043,27 @@ static void rawinput_mouse_enum(running_machine *machine, PRAWINPUTDEVICELIST de
// populate the axes
for (axisnum = 0; axisnum < 3; axisnum++)
{
const char *name = utf8_from_tstring(default_axis_name[axisnum]);
char *name = utf8_from_tstring(default_axis_name[axisnum]);
// add to the mouse device and optionally to the gun device as well
input_device_item_add(devinfo->device, name, &devinfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state);
if (guninfo != NULL && axisnum < 2)
input_device_item_add(guninfo->device, name, &guninfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state);
global_free(name);
osd_free(name);
}
// populate the buttons
for (butnum = 0; butnum < 5; butnum++)
{
const char *name = utf8_from_tstring(default_button_name(butnum));
char *name = utf8_from_tstring(default_button_name(butnum));
// add to the mouse device and optionally to the gun device as well
input_device_item_add(devinfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state);
if (guninfo != NULL)
input_device_item_add(guninfo->device, name, &guninfo->mouse.state.rgbButtons[butnum], (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state);
global_free(name);
osd_free(name);
}
}

View File

@ -83,7 +83,7 @@ extern "C" int _tmain(int argc, TCHAR **argv)
/* free arguments */
for (i = 0; i < argc; i++)
free(utf8_argv[i]);
osd_free(utf8_argv[i]);
free(utf8_argv);
return rc;

View File

@ -65,7 +65,7 @@ CHAR *astring_from_utf8(const char *utf8string)
// convert UTF-16 to "ANSI code page" string
char_count = WideCharToMultiByte(CP_ACP, 0, wstring, -1, NULL, 0, NULL, NULL);
result = (CHAR *)malloc(char_count * sizeof(*result));
result = (CHAR *)osd_malloc(char_count * sizeof(*result));
if (result != NULL)
WideCharToMultiByte(CP_ACP, 0, wstring, -1, result, char_count, NULL, NULL);
@ -90,7 +90,7 @@ char *utf8_from_astring(const CHAR *astring)
// convert UTF-16 to MAME string (UTF-8)
char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL);
result = (CHAR *)malloc(char_count * sizeof(*result));
result = (CHAR *)osd_malloc(char_count * sizeof(*result));
if (result != NULL)
WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL);
@ -109,7 +109,7 @@ WCHAR *wstring_from_utf8(const char *utf8string)
// convert MAME string (UTF-8) to UTF-16
char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0);
result = (WCHAR *)malloc(char_count * sizeof(*result));
result = (WCHAR *)osd_malloc(char_count * sizeof(*result));
if (result != NULL)
MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, result, char_count);
@ -128,7 +128,7 @@ char *utf8_from_wstring(const WCHAR *wstring)
// convert UTF-16 to MAME string (UTF-8)
char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL);
result = (char *)malloc(char_count * sizeof(*result));
result = (char *)osd_malloc(char_count * sizeof(*result));
if (result != NULL)
WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL);

View File

@ -50,11 +50,13 @@
// FUNCTION PROTOTYPES
//============================================================
CHAR *astring_from_utf8(const char *s) ATTR_MALLOC;
char *utf8_from_astring(const CHAR *s) ATTR_MALLOC;
// the result of these functions has to be released with osd_free()
WCHAR *wstring_from_utf8(const char *s) ATTR_MALLOC;
char *utf8_from_wstring(const WCHAR *s) ATTR_MALLOC;
CHAR *astring_from_utf8(const char *s);
char *utf8_from_astring(const CHAR *s);
WCHAR *wstring_from_utf8(const char *s);
char *utf8_from_wstring(const WCHAR *s);
#ifdef UNICODE
#define tstring_from_utf8 wstring_from_utf8

View File

@ -263,7 +263,7 @@ static void init_monitors(void)
if (utf8_device != NULL)
{
mame_printf_verbose("Video: Monitor %p = \"%s\" %s\n", monitor->handle, utf8_device, (monitor == primary_monitor) ? "(primary)" : "");
global_free(utf8_device);
osd_free(utf8_device);
}
}
}
@ -349,7 +349,7 @@ static win_monitor_info *pick_monitor(int index)
if (utf8_device != NULL)
{
rc = strcmp(scrname, utf8_device);
global_free(utf8_device);
osd_free(utf8_device);
}
if (rc == 0)
goto finishit;

View File

@ -110,7 +110,7 @@ osd_directory *osd_opendir(const char *dirname)
error:
// cleanup
if (t_dirname != NULL)
free(t_dirname);
osd_free(t_dirname);
if (dirfilter != NULL)
free(dirfilter);
if (dir != NULL && dir->find == INVALID_HANDLE_VALUE)
@ -131,7 +131,7 @@ const osd_directory_entry *osd_readdir(osd_directory *dir)
// if we've previously allocated a name, free it now
if (dir->entry.name != NULL)
{
free((void *)dir->entry.name);
osd_free((void *)dir->entry.name);
dir->entry.name = NULL;
}
@ -162,7 +162,7 @@ void osd_closedir(osd_directory *dir)
{
// free any data associated
if (dir->entry.name != NULL)
free((void *)dir->entry.name);
osd_free((void *)dir->entry.name);
if (dir->find != INVALID_HANDLE_VALUE)
FindClose(dir->find);
free(dir);
@ -180,7 +180,7 @@ int osd_is_absolute_path(const char *path)
if (t_path != NULL)
{
result = !PathIsRelative(t_path);
free(t_path);
osd_free(t_path);
}
return result;
}

View File

@ -181,7 +181,7 @@ error:
free(*file);
*file = NULL;
}
free(t_path);
osd_free(t_path);
return filerr;
}
@ -276,7 +276,7 @@ file_error osd_rmfile(const char *filename)
done:
if (tempstr)
free(tempstr);
osd_free(tempstr);
return filerr;
}
@ -302,7 +302,7 @@ int osd_get_physical_drive_geometry(const char *filename, UINT32 *cylinders, UIN
if (t_filename == NULL)
return FALSE;
file = CreateFile(t_filename, GENERIC_READ, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL);
free(t_filename);
osd_free(t_filename);
if (file == INVALID_HANDLE_VALUE)
return FALSE;
@ -456,7 +456,7 @@ osd_directory_entry *osd_stat(const char *path)
done:
if (t_path != NULL)
free(t_path);
osd_free(t_path);
return result;
}
@ -497,7 +497,7 @@ file_error osd_get_full_path(char **dst, const char *path)
done:
if (t_path != NULL)
free(t_path);
osd_free(t_path);
return err;
}

View File

@ -60,7 +60,7 @@ void win_output_debug_string_utf8(const char *string)
if (t_string != NULL)
{
OutputDebugString(t_string);
free(t_string);
osd_free(t_string);
}
}
@ -83,7 +83,7 @@ DWORD win_get_module_file_name_utf8(HMODULE module, char *filename, DWORD size)
return 0;
size = (DWORD) snprintf(filename, size, "%s", utf8_filename);
free(utf8_filename);
osd_free(utf8_filename);
return size;
}
@ -102,7 +102,7 @@ BOOL win_set_file_attributes_utf8(const char* filename, DWORD fileattributes)
result = SetFileAttributes(t_filename, fileattributes);
free(t_filename);
osd_free(t_filename);
return result;
}
@ -125,14 +125,14 @@ BOOL win_copy_file_utf8(const char* existingfilename, const char* newfilename, B
t_newfilename = tstring_from_utf8(newfilename);
if( !t_newfilename ) {
free(t_existingfilename);
osd_free(t_existingfilename);
return result;
}
result = CopyFile(t_existingfilename, t_newfilename, failifexists);
free(t_newfilename);
free(t_existingfilename);
osd_free(t_newfilename);
osd_free(t_existingfilename);
return result;
}
@ -161,8 +161,8 @@ BOOL win_move_file_utf8(const char* existingfilename, const char* newfilename)
result = MoveFile(t_existingfilename, t_newfilename);
free(t_newfilename);
free(t_existingfilename);
osd_free(t_newfilename);
osd_free(t_existingfilename);
return result;
}
@ -197,9 +197,9 @@ int win_message_box_utf8(HWND window, const char *text, const char *caption, UIN
done:
if (t_text)
free(t_text);
osd_free(t_text);
if (t_caption)
free(t_caption);
osd_free(t_caption);
return result;
}
@ -225,7 +225,7 @@ BOOL win_set_window_text_utf8(HWND window, const char *text)
done:
if (t_text)
free(t_text);
osd_free(t_text);
return result;
}
@ -254,7 +254,7 @@ int win_get_window_text_utf8(HWND window, char *buffer, size_t buffer_size)
done:
if (utf8_buffer)
free(utf8_buffer);
osd_free(utf8_buffer);
return result;
}
@ -278,15 +278,15 @@ HWND win_create_window_ex_utf8(DWORD exstyle, const char* classname, const char*
t_windowname = tstring_from_utf8(windowname);
if( !t_windowname ) {
free(t_classname);
osd_free(t_classname);
return result;
}
result = CreateWindowEx(exstyle, t_classname, t_windowname, style, x, y, width, height, parent,
menu, instance, param);
free(t_windowname);
free(t_classname);
osd_free(t_windowname);
osd_free(t_classname);
return result;
}