Previous 15994 Revisions Next

r7844 Saturday 17th April, 2010 at 18:28:29 UTC by Firewave
[MESSUI] Use proper free() calls and renamed some variables to properly reflect type
[src/mess/osd/winui]devview.c messui.c propertiesms.c softwarepicker.c swconfig.c

src/mess/osd/winui/messui.c
r7843r7844
898898static BOOL DevView_GetOpenFileName(HWND hwndDevView, const machine_config *config, const device_config *dev, LPTSTR pszFilename, UINT nFilenameLength)
899899{
900900   BOOL bResult;
901   TCHAR *s;
901   TCHAR *t_s;
902902   int i;
903903   mess_image_type imagetypes[64];
904904   HWND hwndList = GetDlgItem(GetMainWindow(), IDC_LIST);
r7843r7844
907907
908908   /* Get the path to the currently mounted image */
909909   zippath_parent(&as, GetSelectedSoftware(drvindex, config, dev));
910   s = tstring_from_utf8(astring_c(&as));
910   t_s = tstring_from_utf8(astring_c(&as));
911911
912912   /* See if an image was loaded, and that the path still exists */
913913   if ((!osd_opendir(astring_c(&as))) || (astring_chr(&as, 0, ':') == -1))
r7843r7844
918918      /* We only want the first path; throw out the rest */
919919      i = astring_chr(&as, 0, ';');
920920      if (i > 0) astring_substr(&as, 0, i);
921      global_free(s);
922      s = tstring_from_utf8(astring_c(&as));
921      global_free(t_s);
922      t_s = tstring_from_utf8(astring_c(&as));
923923
924924      /* Make sure a folder was specified in the tab, and that it exists */
925925      if ((!osd_opendir(astring_c(&as))) || (astring_chr(&as, 0, ':') == -1))
r7843r7844
930930         /* We only want the first path; throw out the rest */
931931         i = astring_chr(&as, 0, ';');
932932         if (i > 0) astring_substr(&as, 0, i);
933         global_free(s);
934         s = tstring_from_utf8(astring_c(&as));
933         global_free(t_s);
934         t_s = tstring_from_utf8(astring_c(&as));
935935
936936         /* Make sure a folder was specified in the tab, and that it exists */
937937         if ((!osd_opendir(astring_c(&as))) || (astring_chr(&as, 0, ':') == -1))
r7843r7844
940940
941941            osd_get_full_path(&dst,".");
942942            /* Default to emu directory */
943            global_free(s);
944            s = tstring_from_utf8(dst);
943            global_free(t_s);
944            t_s = tstring_from_utf8(dst);
945945
946946            /* If software folder exists, use it instead */
947947            zippath_combine(&as, dst, "software");
948948            if (osd_opendir(astring_c(&as)))
949949            {
950               global_free(s);
951               s = tstring_from_utf8(astring_c(&as));
950               global_free(t_s);
951               t_s = tstring_from_utf8(astring_c(&as));
952952            }
953953            global_free(dst);
954954         }
r7843r7844
956956   }
957957
958958   SetupImageTypes(config, imagetypes, ARRAY_LENGTH(imagetypes), TRUE, dev);
959   bResult = CommonFileImageDialog(s, GetOpenFileName, pszFilename, config, imagetypes);
959   bResult = CommonFileImageDialog(t_s, GetOpenFileName, pszFilename, config, imagetypes);
960960   CleanupImageTypes(imagetypes, ARRAY_LENGTH(imagetypes));
961961   
962   global_free(s);
962   global_free(t_s);
963963
964964   return bResult;
965965}
r7843r7844
977977static BOOL DevView_GetCreateFileName(HWND hwndDevView, const machine_config *config, const device_config *dev, LPTSTR pszFilename, UINT nFilenameLength)
978978{
979979   BOOL bResult;
980   TCHAR *s;
980   TCHAR *t_s;
981981   int i;
982982   mess_image_type imagetypes[64];
983983   HWND hwndList = GetDlgItem(GetMainWindow(), IDC_LIST);
r7843r7844
990990   /* We only want the first path; throw out the rest */
991991   i = astring_chr(&as, 0, ';');
992992   if (i > 0) astring_substr(&as, 0, i);
993   s = tstring_from_utf8(astring_c(&as));
993   t_s = tstring_from_utf8(astring_c(&as));
994994
995995   /* Make sure a folder was specified in the tab, and that it exists */
996996   if ((!osd_opendir(astring_c(&as))) || (astring_chr(&as, 0, ':') == -1))
r7843r7844
10011001      /* We only want the first path; throw out the rest */
10021002      i = astring_chr(&as, 0, ';');
10031003      if (i > 0) astring_substr(&as, 0, i);
1004      global_free(s);
1005      s = tstring_from_utf8(astring_c(&as));
1004      global_free(t_s);
1005      t_s = tstring_from_utf8(astring_c(&as));
10061006
10071007      /* Make sure a folder was specified in the tab, and that it exists */
10081008      if ((!osd_opendir(astring_c(&as))) || (astring_chr(&as, 0, ':') == -1))
r7843r7844
10111011
10121012         osd_get_full_path(&dst,".");
10131013         /* Default to emu directory */
1014         global_free(s);
1015         s = tstring_from_utf8(dst);
1014         global_free(t_s);
1015         t_s = tstring_from_utf8(dst);
10161016
10171017         /* If software folder exists, use it instead */
10181018         zippath_combine(&as, dst, "software");
10191019         if (osd_opendir(astring_c(&as)))
10201020         {
1021            global_free(s);
1022            s = tstring_from_utf8(astring_c(&as));
1021            global_free(t_s);
1022            t_s = tstring_from_utf8(astring_c(&as));
10231023         }
10241024         global_free(dst);
10251025      }
10261026   }
10271027
10281028   SetupImageTypes(config, imagetypes, ARRAY_LENGTH(imagetypes), TRUE, dev);
1029   bResult = CommonFileImageDialog(s, GetSaveFileName, pszFilename, config, imagetypes);
1029   bResult = CommonFileImageDialog(t_s, GetSaveFileName, pszFilename, config, imagetypes);
10301030   CleanupImageTypes(imagetypes, ARRAY_LENGTH(imagetypes));
10311031   
1032   global_free(s);
1032   global_free(t_s);
10331033
10341034   return bResult;
10351035}
src/mess/osd/winui/devview.c
r7843r7844
7070         DestroyWindow(pDevViewInfo->pEntries[i].hwndEdit);
7171         DestroyWindow(pDevViewInfo->pEntries[i].hwndBrowseButton);
7272      }
73      global_free(pDevViewInfo->pEntries);
73      free(pDevViewInfo->pEntries);
7474      pDevViewInfo->pEntries = NULL;
7575   }
7676
r7843r7844
188188   int nStaticPos, nStaticWidth, nEditPos, nEditWidth, nButtonPos, nButtonWidth;
189189   HDC hDc;
190190   LPTSTR *ppszDevices;
191   LPTSTR s;
191   LPTSTR t_s;
192192   SIZE sz;
193193   LONG_PTR l;
194194
r7843r7844
214214         {
215215            image_device_info info = image_device_getinfo(pDevViewInfo->config->mconfig, dev);
216216
217            s = tstring_from_utf8(info.name);
218            ppszDevices[i] = (TCHAR*)alloca((_tcslen(s) + 1) * sizeof(TCHAR));
219            _tcscpy(ppszDevices[i], s);
220            global_free(s);
217            t_s = tstring_from_utf8(info.name);
218            ppszDevices[i] = (TCHAR*)alloca((_tcslen(t_s) + 1) * sizeof(TCHAR));
219            _tcscpy(ppszDevices[i], t_s);
220            global_free(t_s);
221221            i++;
222222         }
223223      }
r7843r7844
379379   DevView_Clear(hwndDevView);
380380   pDevViewInfo = GetDevViewInfo(hwndDevView);
381381   DeleteObject(pDevViewInfo->hFont);
382   global_free(pDevViewInfo);
382   free(pDevViewInfo);
383383}
384384
385385
src/mess/osd/winui/swconfig.c
r7843r7844
5252      hashfile_close(config->hashfile);
5353      config->hashfile = NULL;
5454   }
55   global_free(config);
55   free(config);
5656}
src/mess/osd/winui/softwarepicker.c
r7843r7844
277277                     ComputeFileHash(pPickerInfo, pFileInfo, pBuffer, zipent->uncompressed_length);
278278                     rc = TRUE;
279279                  }
280                  global_free(pBuffer);
280                  free(pBuffer);
281281               }
282282            }
283283            zipent = zip_file_next_file(zip);
r7843r7844
429429
430430   ppNewIndex = (file_info**)malloc((pPickerInfo->file_index_length + 1) * sizeof(*pPickerInfo->file_index));
431431   memcpy(ppNewIndex,pPickerInfo->file_index,pPickerInfo->file_index_length * sizeof(*pPickerInfo->file_index));
432   if (pPickerInfo->file_index) global_free(pPickerInfo->file_index);
432   if (pPickerInfo->file_index) free(pPickerInfo->file_index);
433433   if (!ppNewIndex)
434434      goto error;
435435
r7843r7844
446446
447447error:
448448   if (pInfo)
449      global_free(pInfo);
449      free(pInfo);
450450   return FALSE;
451451}
452452
r7843r7844
562562{
563563   if (pSearchInfo->find_handle != INVALID_HANDLE_VALUE)
564564      FindClose(pSearchInfo->find_handle);
565   global_free(pSearchInfo);
565   free(pSearchInfo);
566566}
567567
568568
r7843r7844
573573   int i;
574574
575575   for (i = 0; i < pPickerInfo->file_index_length; i++)
576      global_free(pPickerInfo->file_index[i]);
576      free(pPickerInfo->file_index[i]);
577577
578578   while(pPickerInfo->first_search_info)
579579   {
r7843r7844
826826   {
827827      SoftwarePicker_InternalClear(pPickerInfo);
828828      SoftwarePicker_SetDriver(hwndPicker, NULL);
829      global_free(pPickerInfo);
829      free(pPickerInfo);
830830   }
831831
832832   return rc;
r7843r7844
857857
858858error:
859859   if (pPickerInfo)
860      global_free(pPickerInfo);
860      free(pPickerInfo);
861861   return FALSE;
862862}
src/mess/osd/winui/propertiesms.c
r7843r7844
283283   int directory_count;
284284    LV_ITEM lvi;
285285   TCHAR buffer[2048];
286   char *dir_list;
286   char *utf8_dir_list;
287287   int i, pos, driver_index;
288288   BOOL res;
289289
r7843r7844
313313      pos += _tcslen(&buffer[pos]);
314314   }
315315
316   dir_list = utf8_from_tstring(buffer);
317   if (dir_list != NULL)
316   utf8_dir_list = utf8_from_tstring(buffer);
317   if (utf8_dir_list != NULL)
318318   {
319319      driver_index = PropertiesCurrentGame(dialog);
320      SetExtraSoftwarePaths(driver_index, dir_list);
321      global_free(dir_list);
320      SetExtraSoftwarePaths(driver_index, utf8_dir_list);
321      global_free(utf8_dir_list);
322322   }
323323   return TRUE;
324324}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team