Previous 15994 Revisions Next

r7938 Thursday 29th April, 2010 at 21:00:17 UTC by Firewave
Fixed strconv.c and other memory leaks (patch submitted to MAMEdev). Maybe cause breakage in newui/winui code - fixes pending.
[src/emu]rendfont.c ui.c
[src/emu/debug]debugvw.c
[src/lib/util]pool.c
[src/osd]osdcore.h
[src/osd/sdl]main.c sdlos_macosx.c sdlos_unix.c sdlos_win32.c strconv.c strconv.h video.c
[src/osd/windows]debugwin.c drawd3d.c input.c main.c strconv.c strconv.h video.c windir.c winfile.c winutf8.c

src/osd/sdl/sdlos_macosx.c
r7937r7938
277277                     length = CFDataGetLength (data_ref);
278278                     range = CFRangeMake (0,length);
279279
280                     result = (char *)malloc (length+1);
280                     result = (char *)osd_malloc (length+1);
281281                     if (result != NULL)
282282                     {
283283                        CFDataGetBytes (data_ref, range, (unsigned char *)result);
r7937r7938
373373   }
374374   else
375375   {
376      *dst = (char *)malloc(strlen(path_buffer)+strlen(path)+3);
376      *dst = (char *)osd_malloc(strlen(path_buffer)+strlen(path)+3);
377377
378378      // if it's already a full path, just pass it through
379379      if (path[0] == '/')
src/osd/sdl/strconv.c
r7937r7938
3838
3939   // convert UTF-16 to MAME string (UTF-8)
4040   char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL);
41   result = (CHAR *)malloc(char_count * sizeof(*result));
41   result = (CHAR *)osd_malloc(char_count * sizeof(*result));
4242   if (result != NULL)
4343      WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL);
4444
r7937r7938
5656
5757   // convert UTF-16 to MAME string (UTF-8)
5858   char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL);
59   result = (char *)malloc(char_count * sizeof(*result));
59   result = (char *)osd_malloc(char_count * sizeof(*result));
6060   if (result != NULL)
6161      WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL);
6262
src/osd/sdl/strconv.h
r7937r7938
2020
2121#ifdef SDLMAME_WIN32
2222
23CHAR *astring_from_utf8(const char *s) ATTR_MALLOC;
24char *utf8_from_astring(const CHAR *s) ATTR_MALLOC;
23// the result of these functions has to be released with osd_free()
2524
26WCHAR *wstring_from_utf8(const char *s) ATTR_MALLOC;
27char *utf8_from_wstring(const WCHAR *s) ATTR_MALLOC;
25CHAR *astring_from_utf8(const char *s);
26char *utf8_from_astring(const CHAR *s);
2827
28WCHAR *wstring_from_utf8(const char *s);
29char *utf8_from_wstring(const WCHAR *s);
30
2931#ifdef UNICODE
3032#define tstring_from_utf8   wstring_from_utf8
3133#define utf8_from_tstring   utf8_from_wstring
src/osd/sdl/sdlos_win32.c
r7937r7938
377377
378378   // convert UTF-16 to "ANSI code page" string
379379   char_count = WideCharToMultiByte(CP_ACP, 0, wstring, -1, NULL, 0, NULL, NULL);
380   result = (CHAR *)malloc(char_count * sizeof(*result));
380   result = (CHAR *)osd_malloc(char_count * sizeof(*result));
381381   if (result != NULL)
382382      WideCharToMultiByte(CP_ACP, 0, wstring, -1, result, char_count, NULL, NULL);
383383
r7937r7938
395395
396396   // convert MAME string (UTF-8) to UTF-16
397397   char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0);
398   result = (WCHAR *)malloc(char_count * sizeof(*result));
398   result = (WCHAR *)osd_malloc(char_count * sizeof(*result));
399399   if (result != NULL)
400400      MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, result, char_count);
401401
r7937r7938
449449
450450done:
451451   if (t_path)
452      free(t_path);
452      osd_free(t_path);
453453   return result;
454454}
455455
r7937r7938
549549
550550done:
551551   if (t_path != NULL)
552      free(t_path);
552      osd_free(t_path);
553553   return err;
554554}
555555
src/osd/sdl/sdlos_unix.c
r7937r7938
293293   }
294294   else
295295   {
296      *dst = (char *)malloc(strlen(path_buffer)+strlen(path)+3);
296      *dst = (char *)osd_malloc(strlen(path_buffer)+strlen(path)+3);
297297
298298      // if it's already a full path, just pass it through
299299      if (path[0] == '/')
src/osd/sdl/video.c
r7937r7938
192192   monitor->center_height = monitor->monitor_height = info.rcMonitor.bottom - info.rcMonitor.top;
193193   char *temp = utf8_from_wstring(info.szDevice);
194194   strcpy(monitor->monitor_device, temp);
195   global_free(temp);
195   osd_free(temp);
196196   #elif defined(SDLMAME_MACOSX)   // Mac OS X Core Imaging version
197197   CGDirectDisplayID primary;
198198   CGRect dbounds;
r7937r7938
421421   monitor->monitor_height = info.rcMonitor.bottom - info.rcMonitor.top;
422422   char *temp = utf8_from_wstring(info.szDevice);
423423   strcpy(monitor->monitor_device, temp);
424   global_free(temp);
424   osd_free(temp);
425425
426426   // guess the aspect ratio assuming square pixels
427427   monitor->aspect = (float)(info.rcMonitor.right - info.rcMonitor.left) / (float)(info.rcMonitor.bottom - info.rcMonitor.top);
src/osd/sdl/main.c
r7937r7938
6060
6161   /* free arguments */
6262   for (i = 0; i < argc; i++)
63      free(utf8_argv[i]);
63      osd_free(utf8_argv[i]);
6464   free(utf8_argv);
6565
6666#ifdef MALLOC_DEBUG
src/osd/osdcore.h
r7937r7938
822822
823823    Return value:
824824
825        the returned string needs to be free()-ed!
825        the returned string needs to be osd_free()-ed!
826826
827827-----------------------------------------------------------------------------*/
828828char *osd_get_clipboard_text(void);
r7937r7938
858858    Parameters:
859859
860860        path - the path in question
861        dst - pointer to receive new path; the returned string needs to be free()-ed!
861        dst - pointer to receive new path; the returned string needs to be osd_free()-ed!
862862
863863    Return value:
864864
src/osd/windows/strconv.c
r7937r7938
6565
6666   // convert UTF-16 to "ANSI code page" string
6767   char_count = WideCharToMultiByte(CP_ACP, 0, wstring, -1, NULL, 0, NULL, NULL);
68   result = (CHAR *)malloc(char_count * sizeof(*result));
68   result = (CHAR *)osd_malloc(char_count * sizeof(*result));
6969   if (result != NULL)
7070      WideCharToMultiByte(CP_ACP, 0, wstring, -1, result, char_count, NULL, NULL);
7171
r7937r7938
9090
9191   // convert UTF-16 to MAME string (UTF-8)
9292   char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL);
93   result = (CHAR *)malloc(char_count * sizeof(*result));
93   result = (CHAR *)osd_malloc(char_count * sizeof(*result));
9494   if (result != NULL)
9595      WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL);
9696
r7937r7938
109109
110110   // convert MAME string (UTF-8) to UTF-16
111111   char_count = MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, NULL, 0);
112   result = (WCHAR *)malloc(char_count * sizeof(*result));
112   result = (WCHAR *)osd_malloc(char_count * sizeof(*result));
113113   if (result != NULL)
114114      MultiByteToWideChar(CP_UTF8, 0, utf8string, -1, result, char_count);
115115
r7937r7938
128128
129129   // convert UTF-16 to MAME string (UTF-8)
130130   char_count = WideCharToMultiByte(CP_UTF8, 0, wstring, -1, NULL, 0, NULL, NULL);
131   result = (char *)malloc(char_count * sizeof(*result));
131   result = (char *)osd_malloc(char_count * sizeof(*result));
132132   if (result != NULL)
133133      WideCharToMultiByte(CP_UTF8, 0, wstring, -1, result, char_count, NULL, NULL);
134134
src/osd/windows/strconv.h
r7937r7938
5050//  FUNCTION PROTOTYPES
5151//============================================================
5252
53CHAR *astring_from_utf8(const char *s) ATTR_MALLOC;
54char *utf8_from_astring(const CHAR *s) ATTR_MALLOC;
53// the result of these functions has to be released with osd_free()
5554
56WCHAR *wstring_from_utf8(const char *s) ATTR_MALLOC;
57char *utf8_from_wstring(const WCHAR *s) ATTR_MALLOC;
55CHAR *astring_from_utf8(const char *s);
56char *utf8_from_astring(const CHAR *s);
5857
58WCHAR *wstring_from_utf8(const char *s);
59char *utf8_from_wstring(const WCHAR *s);
60
5961#ifdef UNICODE
6062#define tstring_from_utf8   wstring_from_utf8
6163#define utf8_from_tstring   utf8_from_wstring
src/osd/windows/windir.c
r7937r7938
110110error:
111111   // cleanup
112112   if (t_dirname != NULL)
113      free(t_dirname);
113      osd_free(t_dirname);
114114   if (dirfilter != NULL)
115115      free(dirfilter);
116116   if (dir != NULL && dir->find == INVALID_HANDLE_VALUE)
r7937r7938
131131   // if we've previously allocated a name, free it now
132132   if (dir->entry.name != NULL)
133133   {
134      free((void *)dir->entry.name);
134      osd_free((void *)dir->entry.name);
135135      dir->entry.name = NULL;
136136   }
137137
r7937r7938
162162{
163163   // free any data associated
164164   if (dir->entry.name != NULL)
165      free((void *)dir->entry.name);
165      osd_free((void *)dir->entry.name);
166166   if (dir->find != INVALID_HANDLE_VALUE)
167167      FindClose(dir->find);
168168   free(dir);
r7937r7938
180180   if (t_path != NULL)
181181   {
182182      result = !PathIsRelative(t_path);
183      free(t_path);
183      osd_free(t_path);
184184   }
185185   return result;
186186}
src/osd/windows/winfile.c
r7937r7938
181181      free(*file);
182182      *file = NULL;
183183   }
184   free(t_path);
184   osd_free(t_path);
185185   return filerr;
186186}
187187
r7937r7938
276276
277277done:
278278   if (tempstr)
279      free(tempstr);
279      osd_free(tempstr);
280280   return filerr;
281281}
282282
r7937r7938
302302   if (t_filename == NULL)
303303      return FALSE;
304304   file = CreateFile(t_filename, GENERIC_READ, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL);
305   free(t_filename);
305   osd_free(t_filename);
306306   if (file == INVALID_HANDLE_VALUE)
307307      return FALSE;
308308
r7937r7938
456456
457457done:
458458   if (t_path != NULL)
459      free(t_path);
459      osd_free(t_path);
460460   return result;
461461}
462462
r7937r7938
497497
498498done:
499499   if (t_path != NULL)
500      free(t_path);
500      osd_free(t_path);
501501   return err;
502502}
503503
src/osd/windows/input.c
r7937r7938
276276static HRESULT dinput_set_dword_property(LPDIRECTINPUTDEVICE device, REFGUID property_guid, DWORD object, DWORD how, DWORD value);
277277static device_info *dinput_device_create(running_machine *machine, device_info **devlist_head_ptr, LPCDIDEVICEINSTANCE instance, LPCDIDATAFORMAT format1, LPCDIDATAFORMAT format2, DWORD cooperative_level);
278278static void dinput_device_release(device_info *devinfo);
279static const char *dinput_device_item_name(device_info *devinfo, int offset, const TCHAR *defstring, const TCHAR *suffix);
279static char *dinput_device_item_name(device_info *devinfo, int offset, const TCHAR *defstring, const TCHAR *suffix);
280280static HRESULT dinput_device_poll(device_info *devinfo);
281281static BOOL CALLBACK dinput_keyboard_enum(LPCDIDEVICEINSTANCE instance, LPVOID ref);
282282static void dinput_keyboard_poll(device_info *devinfo);
r7937r7938
853853
854854   // free the copy of the name if present
855855   if (devinfo->name != NULL)
856      global_free((void *)devinfo->name);
856      osd_free((void *)devinfo->name);
857857   devinfo->name = NULL;
858858
859859   // and now free the info
r7937r7938
968968      // populate the axes
969969      for (axisnum = 0; axisnum < 2; axisnum++)
970970      {
971         const char *name = utf8_from_tstring(default_axis_name[axisnum]);
971         char *name = utf8_from_tstring(default_axis_name[axisnum]);
972972         input_device_item_add(devinfo->device, name, &devinfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state);
973         global_free(name);
973         osd_free(name);
974974      }
975975
976976      // populate the buttons
977977      for (butnum = 0; butnum < 2; butnum++)
978978      {
979         const char *name = utf8_from_tstring(default_button_name(butnum));
979         char *name = utf8_from_tstring(default_button_name(butnum));
980980         input_device_item_add(devinfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state);
981         global_free(name);
981         osd_free(name);
982982      }
983983   }
984984}
r7937r7938
12641264//  dinput_device_item_name
12651265//============================================================
12661266
1267static const char *dinput_device_item_name(device_info *devinfo, int offset, const TCHAR *defstring, const TCHAR *suffix)
1267static char *dinput_device_item_name(device_info *devinfo, int offset, const TCHAR *defstring, const TCHAR *suffix)
12681268{
12691269   DIDEVICEOBJECTINSTANCE instance = { 0 };
12701270   const TCHAR *namestring = instance.tszName;
r7937r7938
13501350   {
13511351      input_item_id itemid = keyboard_map_scancode_to_itemid(keynum);
13521352      TCHAR defname[20];
1353      const char *name;
1353      char *name;
13541354
13551355      // generate/fetch the name
13561356      _sntprintf(defname, ARRAY_LENGTH(defname), TEXT("Scan%03d"), keynum);
r7937r7938
13581358
13591359      // add the item to the device
13601360      input_device_item_add(devinfo->device, name, &devinfo->keyboard.state[keynum], itemid, generic_button_get_state);
1361      global_free(name);
1361      osd_free(name);
13621362   }
13631363
13641364exit:
r7937r7938
14301430   // populate the axes
14311431   for (axisnum = 0; axisnum < devinfo->dinput.caps.dwAxes; axisnum++)
14321432   {
1433      const char *name = dinput_device_item_name(devinfo, offsetof(DIMOUSESTATE, lX) + axisnum * sizeof(LONG), default_axis_name[axisnum], NULL);
1433      char *name = dinput_device_item_name(devinfo, offsetof(DIMOUSESTATE, lX) + axisnum * sizeof(LONG), default_axis_name[axisnum], NULL);
14341434
14351435      // add to the mouse device and optionally to the gun device as well
14361436      input_device_item_add(devinfo->device, name, &devinfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state);
14371437      if (guninfo != NULL && axisnum < 2)
14381438         input_device_item_add(guninfo->device, name, &guninfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state);
14391439
1440      global_free(name);
1440      osd_free(name);
14411441   }
14421442
14431443   // populate the buttons
14441444   for (butnum = 0; butnum < devinfo->dinput.caps.dwButtons; butnum++)
14451445   {
14461446      FPTR offset = (FPTR)(&((DIMOUSESTATE *)NULL)->rgbButtons[butnum]);
1447      const char *name = dinput_device_item_name(devinfo, offset, default_button_name(butnum), NULL);
1447      char *name = dinput_device_item_name(devinfo, offset, default_button_name(butnum), NULL);
14481448
14491449      // add to the mouse device and optionally to the gun device as well
14501450      // note that the gun device points to the mouse buttons rather than its own
r7937r7938
14521452      if (guninfo != NULL)
14531453         input_device_item_add(guninfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state);
14541454
1455      global_free(name);
1455      osd_free(name);
14561456   }
14571457
14581458exit:
r7937r7938
15281528   for (axisnum = axiscount = 0; axiscount < devinfo->dinput.caps.dwAxes && axisnum < 8; axisnum++)
15291529   {
15301530      DIPROPRANGE dipr;
1531      const char *name;
1531      char *name;
15321532
15331533      // fetch the range of this axis
15341534      dipr.diph.dwSize = sizeof(dipr);
r7937r7938
15441544      // populate the item description as well
15451545      name = dinput_device_item_name(devinfo, offsetof(DIJOYSTATE2, lX) + axisnum * sizeof(LONG), default_axis_name[axisnum], NULL);
15461546      input_device_item_add(devinfo->device, name, &devinfo->joystick.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state);
1547      global_free(name);
1547      osd_free(name);
15481548
15491549      axiscount++;
15501550   }
r7937r7938
15521552   // populate the POVs
15531553   for (povnum = 0; povnum < devinfo->dinput.caps.dwPOVs; povnum++)
15541554   {
1555      const char *name;
1555      char *name;
15561556
15571557      // left
15581558      name = dinput_device_item_name(devinfo, offsetof(DIJOYSTATE2, rgdwPOV) + povnum * sizeof(DWORD), default_pov_name(povnum), TEXT("L"));
15591559      input_device_item_add(devinfo->device, name, (void *)(FPTR)(povnum * 4 + POVDIR_LEFT), ITEM_ID_OTHER_SWITCH, dinput_joystick_pov_get_state);
1560      global_free(name);
1560      osd_free(name);
15611561
15621562      // right
15631563      name = dinput_device_item_name(devinfo, offsetof(DIJOYSTATE2, rgdwPOV) + povnum * sizeof(DWORD), default_pov_name(povnum), TEXT("R"));
15641564      input_device_item_add(devinfo->device, name, (void *)(FPTR)(povnum * 4 + POVDIR_RIGHT), ITEM_ID_OTHER_SWITCH, dinput_joystick_pov_get_state);
1565      global_free(name);
1565      osd_free(name);
15661566
15671567      // up
15681568      name = dinput_device_item_name(devinfo, offsetof(DIJOYSTATE2, rgdwPOV) + povnum * sizeof(DWORD), default_pov_name(povnum), TEXT("U"));
15691569      input_device_item_add(devinfo->device, name, (void *)(FPTR)(povnum * 4 + POVDIR_UP), ITEM_ID_OTHER_SWITCH, dinput_joystick_pov_get_state);
1570      global_free(name);
1570      osd_free(name);
15711571
15721572      // down
15731573      name = dinput_device_item_name(devinfo, offsetof(DIJOYSTATE2, rgdwPOV) + povnum * sizeof(DWORD), default_pov_name(povnum), TEXT("D"));
15741574      input_device_item_add(devinfo->device, name, (void *)(FPTR)(povnum * 4 + POVDIR_DOWN), ITEM_ID_OTHER_SWITCH, dinput_joystick_pov_get_state);
1575      global_free(name);
1575      osd_free(name);
15761576   }
15771577
15781578   // populate the buttons
15791579   for (butnum = 0; butnum < devinfo->dinput.caps.dwButtons; butnum++)
15801580   {
15811581      FPTR offset = (FPTR)(&((DIJOYSTATE2 *)NULL)->rgbButtons[butnum]);
1582      const char *name = dinput_device_item_name(devinfo, offset, default_button_name(butnum), NULL);
1582      char *name = dinput_device_item_name(devinfo, offset, default_button_name(butnum), NULL);
15831583      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);
1584      global_free(name);
1584      osd_free(name);
15851585   }
15861586
15871587exit:
r7937r7938
19671967   {
19681968      input_item_id itemid = keyboard_map_scancode_to_itemid(keynum);
19691969      TCHAR keyname[100];
1970      const char *name;
1970      char *name;
19711971
19721972      // generate the name
19731973      if (GetKeyNameText(((keynum & 0x7f) << 16) | ((keynum & 0x80) << 17), keyname, ARRAY_LENGTH(keyname)) == 0)
r7937r7938
19761976
19771977      // add the item to the device
19781978      input_device_item_add(devinfo->device, name, &devinfo->keyboard.state[keynum], itemid, generic_button_get_state);
1979      global_free(name);
1979      osd_free(name);
19801980   }
19811981}
19821982
r7937r7938
20432043   // populate the axes
20442044   for (axisnum = 0; axisnum < 3; axisnum++)
20452045   {
2046      const char *name = utf8_from_tstring(default_axis_name[axisnum]);
2046      char *name = utf8_from_tstring(default_axis_name[axisnum]);
20472047
20482048      // add to the mouse device and optionally to the gun device as well
20492049      input_device_item_add(devinfo->device, name, &devinfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state);
20502050      if (guninfo != NULL && axisnum < 2)
20512051         input_device_item_add(guninfo->device, name, &guninfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state);
20522052
2053      global_free(name);
2053      osd_free(name);
20542054   }
20552055
20562056   // populate the buttons
20572057   for (butnum = 0; butnum < 5; butnum++)
20582058   {
2059      const char *name = utf8_from_tstring(default_button_name(butnum));
2059      char *name = utf8_from_tstring(default_button_name(butnum));
20602060
20612061      // add to the mouse device and optionally to the gun device as well
20622062      input_device_item_add(devinfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state);
20632063      if (guninfo != NULL)
20642064         input_device_item_add(guninfo->device, name, &guninfo->mouse.state.rgbButtons[butnum], (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state);
20652065
2066      global_free(name);
2066      osd_free(name);
20672067   }
20682068}
20692069
src/osd/windows/winutf8.c
r7937r7938
6060   if (t_string != NULL)
6161   {
6262      OutputDebugString(t_string);
63      free(t_string);
63      osd_free(t_string);
6464   }
6565}
6666
r7937r7938
8383      return 0;
8484
8585   size = (DWORD) snprintf(filename, size, "%s", utf8_filename);
86   free(utf8_filename);
86   osd_free(utf8_filename);
8787   return size;
8888}
8989
r7937r7938
102102
103103   result = SetFileAttributes(t_filename, fileattributes);
104104
105   free(t_filename);
105   osd_free(t_filename);
106106
107107   return result;
108108}
r7937r7938
125125
126126   t_newfilename = tstring_from_utf8(newfilename);
127127   if( !t_newfilename ) {
128      free(t_existingfilename);
128      osd_free(t_existingfilename);
129129      return result;
130130   }
131131
132132   result = CopyFile(t_existingfilename, t_newfilename, failifexists);
133133
134   free(t_newfilename);
135   free(t_existingfilename);
134   osd_free(t_newfilename);
135   osd_free(t_existingfilename);
136136
137137   return result;
138138}
r7937r7938
161161
162162   result = MoveFile(t_existingfilename, t_newfilename);
163163
164   free(t_newfilename);
165   free(t_existingfilename);
164   osd_free(t_newfilename);
165   osd_free(t_existingfilename);
166166
167167   return result;
168168}
r7937r7938
197197
198198done:
199199   if (t_text)
200      free(t_text);
200      osd_free(t_text);
201201   if (t_caption)
202      free(t_caption);
202      osd_free(t_caption);
203203   return result;
204204}
205205
r7937r7938
225225
226226done:
227227   if (t_text)
228      free(t_text);
228      osd_free(t_text);
229229   return result;
230230}
231231
r7937r7938
254254
255255done:
256256   if (utf8_buffer)
257      free(utf8_buffer);
257      osd_free(utf8_buffer);
258258   return result;
259259}
260260
r7937r7938
278278
279279   t_windowname = tstring_from_utf8(windowname);
280280   if( !t_windowname ) {
281      free(t_classname);
281      osd_free(t_classname);
282282      return result;
283283   }
284284
285285   result = CreateWindowEx(exstyle, t_classname, t_windowname, style, x, y, width, height, parent,
286286                     menu, instance, param);
287287
288   free(t_windowname);
289   free(t_classname);
288   osd_free(t_windowname);
289   osd_free(t_classname);
290290
291291   return result;
292292}
src/osd/windows/debugwin.c
r7937r7938
430430         t_face = tstring_from_utf8(options_get_string(mame_options(), WINOPTION_DEBUGGER_FONT));
431431         debug_font = CreateFont(-MulDiv(size, GetDeviceCaps(temp_dc, LOGPIXELSY), 72), 0, 0, 0, FW_MEDIUM, FALSE, FALSE, FALSE,
432432                  ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, t_face);
433         global_free(t_face);
433         osd_free(t_face);
434434
435435         // fall back to Lucida Console 8
436436         if (debug_font == NULL)
r7937r7938
15741574                     if (utf8_buffer != NULL)
15751575                     {
15761576                        (*info->process_string)(info, utf8_buffer);
1577                        global_free(utf8_buffer);
1577                        osd_free(utf8_buffer);
15781578                     }
15791579                  }
15801580                  break;
r7937r7938
17771777   {
17781778      TCHAR *t_name = tstring_from_utf8(subview->name);
17791779      int item = SendMessage(info->otherwnd[0], CB_ADDSTRING, 0, (LPARAM)t_name);
1780      global_free(t_name);
1780      osd_free(t_name);
17811781      if (cursel == -1 && subview->space != NULL && subview->space->cpu == curcpu)
17821782         cursel = item;
17831783   }
r7937r7938
20862086   {
20872087      TCHAR *t_name = tstring_from_utf8(subview->name);
20882088      int item = SendMessage(info->otherwnd[0], CB_ADDSTRING, 0, (LPARAM)t_name);
2089      global_free(t_name);
2089      osd_free(t_name);
20902090      if (cursel == 0 && subview->space->cpu == curcpu)
20912091         cursel = item;
20922092   }
src/osd/windows/video.c
r7937r7938
263263         if (utf8_device != NULL)
264264         {
265265            mame_printf_verbose("Video: Monitor %p = \"%s\" %s\n", monitor->handle, utf8_device, (monitor == primary_monitor) ? "(primary)" : "");
266            global_free(utf8_device);
266            osd_free(utf8_device);
267267         }
268268      }
269269   }
r7937r7938
349349         if (utf8_device != NULL)
350350         {
351351            rc = strcmp(scrname, utf8_device);
352            global_free(utf8_device);
352            osd_free(utf8_device);
353353         }
354354         if (rc == 0)
355355            goto finishit;
src/osd/windows/main.c
r7937r7938
8383
8484   /* free arguments */
8585   for (i = 0; i < argc; i++)
86      free(utf8_argv[i]);
86      osd_free(utf8_argv[i]);
8787   free(utf8_argv);
8888
8989   return rc;
src/osd/windows/drawd3d.c
r7937r7938
12001200         if (utf8_device != NULL)
12011201         {
12021202            mame_printf_error("Device %s currently in an unsupported mode\n", utf8_device);
1203            global_free(utf8_device);
1203            osd_free(utf8_device);
12041204         }
12051205         return 1;
12061206      }
r7937r7938
12281228      if (utf8_device != NULL)
12291229      {
12301230         mame_printf_error("Proposed video mode not supported on device %s\n", utf8_device);
1231         global_free(utf8_device);
1231         osd_free(utf8_device);
12321232      }
12331233      return 1;
12341234   }
src/emu/debug/debugvw.c
r7937r7938
489489         if (size > view->viewdata_size)
490490         {
491491            view->viewdata_size = size;
492            global_free(view->viewdata);
492            auto_free(view->machine, view->viewdata);
493493            view->viewdata = auto_alloc_array(view->machine, debug_view_char, view->viewdata_size);
494494         }
495495
src/emu/rendfont.c
r7937r7938
482482      global_free(data);
483483
484484   /* close the file */
485   global_free(cachedname);
485   osd_free(cachedname);
486486   mame_fclose(file);
487487   return result;
488488
489489error:
490490   /* close the file */
491491   if (cachedname != NULL)
492      global_free(cachedname);
492      osd_free(cachedname);
493493   if (data != NULL)
494494      global_free(data);
495495   mame_fclose(file);
src/emu/ui.c
r7937r7938
12461246      inputx_post_utf8(machine, text);
12471247
12481248      /* free the string */
1249      free(text);
1249      osd_free(text);
12501250   }
12511251}
12521252
src/lib/util/pool.c
r7937r7938
247247
248248
249249/*-------------------------------------------------
250    pool_free - frees a memory pool and all
250    pool_free_lib - frees a memory pool and all
251251    contained memory blocks
252252-------------------------------------------------*/
253253

Previous 15994 Revisions Next


© 1998-2018 The MESS Team