Previous 15994 Revisions Next

r7843 Saturday 17th April, 2010 at 18:16:43 UTC by Firewave
[WINUI] Use proper free() calls and renamed some variables to properly reflect type
[src/osd/winui]directories.c dirwatch.c picker.c properties.c screenshot.c splitters.c tabview.c treeview.c winui.c

src/osd/winui/tabview.c
r7842r7843
7575   switch(message)
7676   {
7777      case WM_DESTROY:
78         global_free(pTabViewInfo);
78         free(pTabViewInfo);
7979         SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR) pfnParentWndProc);
8080         SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR) NULL);
8181         break;
src/osd/winui/directories.c
r7842r7843
5454typedef struct
5555{
5656   tPath   *m_Path;
57   TCHAR   *m_Directory;
57   TCHAR   *m_tDirectory;
5858} tDirInfo;
5959
6060/***************************************************************************
r7842r7843
147147
148148static void DirInfo_SetDir(tDirInfo *pInfo, int nType, int nItem, LPCTSTR pText)
149149{
150   TCHAR *s;
151   TCHAR *pOldText;
150   TCHAR *t_s;
151   TCHAR *t_pOldText;
152152
153153   if (IsMultiDir(nType))
154154   {
r7842r7843
158158   }
159159   else
160160   {
161      s = win_tstring_strdup(pText);
162      if (!s)
161      t_s = win_tstring_strdup(pText);
162      if (!t_s)
163163         return;
164      pOldText = pInfo[nType].m_Directory;
165      if (pOldText)
166         global_free(pOldText);
167      pInfo[nType].m_Directory = s;
164      t_pOldText = pInfo[nType].m_tDirectory;
165      if (t_pOldText)
166         global_free(t_pOldText);
167      pInfo[nType].m_tDirectory = t_s;
168168   }
169169}
170170
171171static TCHAR* DirInfo_Dir(tDirInfo *pInfo, int nType)
172172{
173173   assert(!IsMultiDir(nType));
174   return pInfo[nType].m_Directory;
174   return pInfo[nType].m_tDirectory;
175175}
176176
177177static TCHAR* DirInfo_Path(tDirInfo *pInfo, int nType, int nItem)
r7842r7843
366366      for (i = 0; i < nDirInfoCount; i++)
367367      {
368368         if (g_pDirInfo[i].m_Path)
369            global_free(g_pDirInfo[i].m_Path);
370         if (g_pDirInfo[i].m_Directory)
371            global_free(g_pDirInfo[i].m_Directory);         
369            free(g_pDirInfo[i].m_Path);
370         if (g_pDirInfo[i].m_tDirectory)
371            global_free(g_pDirInfo[i].m_tDirectory);
372372      }
373      global_free(g_pDirInfo);
373      free(g_pDirInfo);
374374      g_pDirInfo = NULL;
375375   }
376376}
src/osd/winui/screenshot.c
r7842r7843
211211      header = zip_file_next_file(zip);
212212   }
213213
214   global_free(new_filename);
214   free(new_filename);
215215   return header;
216216}
217217
r7842r7843
345345
346346   // free the buffer if we have to
347347   if (buffer != NULL) {
348      global_free(buffer);
348      free(buffer);
349349   }
350350   return success;
351351}
r7842r7843
498498     
499499      *pPal = CreatePalette(pLP);
500500     
501      global_free (pLP);
501      free (pLP);
502502   }
503503   
504504   copy_size = dibSize;
r7842r7843
520520   if (p.color_type != 3 && p.color_type != 2)
521521   {
522522      logerror("Unsupported color type %i (has to be 3)\n", p.color_type);
523      global_free(p.image);
523      png_free(&p);
524524      return 0;
525525   }
526526   if (p.interlace_method != 0)
527527   {
528528      logerror("Interlace unsupported\n");
529      global_free (p.image);
529      png_free(&p);
530530      return 0;
531531   }
532532 
r7842r7843
536536   if (!AllocatePNG(&p, phDIB, pPAL))
537537   {
538538      logerror("Unable to allocate memory for artwork\n");
539      global_free(p.image);
539      png_free(&p);
540540      return 0;
541541   }
542542
r7842r7843
562562      store_pixels(p.image + i * (p.width * bytespp), p.width * bytespp);
563563   }
564564
565   global_free(p.image);
565   png_free(&p);
566566
567567   return 1;
568568}
src/osd/winui/picker.c
r7842r7843
256256{
257257   // Free up all resources associated with this picker structure
258258   if (pPickerInfo->pnColumnsShown)
259      global_free(pPickerInfo->pnColumnsShown);
259      free(pPickerInfo->pnColumnsShown);
260260   if (pPickerInfo->pnColumnsOrder)
261      global_free(pPickerInfo->pnColumnsOrder);
262   global_free(pPickerInfo);
261      free(pPickerInfo->pnColumnsOrder);
262   free(pPickerInfo);
263263}
264264
265265
r7842r7843
420420
421421done:
422422   if (widths)
423      global_free(widths);
423      free(widths);
424424   if (order)
425      global_free(order);
425      free(order);
426426   if (shown)
427      global_free(shown);
427      free(shown);
428428}
429429
430430
r7842r7843
11721172      }
11731173   }
11741174
1175   global_free(shown);
1175   free(shown);
11761176   return nColumnCount;
11771177}
11781178
r7842r7843
15691569
15701570   SetTextColor(hDC, clrTextSave);
15711571   SetBkColor(hDC, clrBkSave);
1572   global_free(order);
1572   free(order);
15731573}
15741574
15751575
r7842r7843
16691669
16701670done:
16711671   if (widths)
1672      global_free(widths);
1672      free(widths);
16731673   if (order)
1674      global_free(order);
1674      free(order);
16751675   if (tmpOrder)
1676      global_free(tmpOrder);
1676      free(tmpOrder);
16771677   return bSuccess;
16781678}
src/osd/winui/splitters.c
r7842r7843
7474{
7575   if (splitter)
7676   {
77      global_free(splitter);
77      free(splitter);
7878      splitter = NULL;
7979   }
8080   if (nSplitterOffset)
8181   {
82      global_free(nSplitterOffset);
82      free(nSplitterOffset);
8383      nSplitterOffset = NULL;
8484   }
8585}
src/osd/winui/dirwatch.c
r7842r7843
9696{
9797   if (pEntry->hDir)
9898      CloseHandle(pEntry->hDir);
99   global_free(pEntry);
99   free(pEntry);
100100}
101101
102102
r7842r7843
368368      CloseHandle(pWatcher->hRequestEvent);
369369   if (pWatcher->hResponseEvent)
370370      CloseHandle(pWatcher->hResponseEvent);
371   global_free(pWatcher);
371   free(pWatcher);
372372}
373373
374374
src/osd/winui/treeview.c
r7842r7843
194194         treeFolders[i] = NULL;
195195         numFolders--;
196196      }
197      global_free(treeFolders);
197      free(treeFolders);
198198      treeFolders = NULL;
199199   }
200200   numFolders = 0;
r7842r7843
15181518      folderArrayLength += 500;
15191519      tmpTree = (TREEFOLDER **)malloc(sizeof(TREEFOLDER **) * folderArrayLength);
15201520      memcpy(tmpTree,treeFolders,sizeof(TREEFOLDER **) * oldFolderArrayLength);
1521      if (treeFolders) global_free(treeFolders);
1521      if (treeFolders) free(treeFolders);
15221522      treeFolders = tmpTree;
15231523   }
15241524
r7842r7843
15611561      }
15621562      global_free(lpFolder->m_lptTitle);
15631563      lpFolder->m_lptTitle = 0;
1564      global_free(lpFolder->m_lpTitle);
1564      free(lpFolder->m_lpTitle);
15651565      lpFolder->m_lpTitle = 0;
1566      global_free(lpFolder);
1566      free(lpFolder);
15671567      lpFolder = 0;
15681568   }
15691569}
r7842r7843
20472047   {
20482048      if (ExtraFolderData[i])
20492049      {
2050         global_free(ExtraFolderData[i]);
2050         free(ExtraFolderData[i]);
20512051         ExtraFolderData[i] = NULL;
20522052      }
20532053   }
20542054
20552055   for (i = 0; i < numExtraIcons; i++)
20562056    {
2057      global_free(ExtraFolderIcons[i]);
2057      free(ExtraFolderIcons[i]);
20582058    }
20592059
20602060   numExtraIcons = 0;
r7842r7843
22522252      if (TrySaveExtraFolder(lpFolder) == FALSE)
22532253      {
22542254         // failed, so free newly allocated title and restore old
2255         global_free(lpFolder->m_lpTitle);
2255         free(lpFolder->m_lpTitle);
22562256         lpFolder->m_lpTitle = old_title;
22572257         return FALSE;
22582258      }
22592259      TryRenameCustomFolderIni(lpFolder, old_title, new_name);
22602260      // successful, so free old title
2261      global_free(old_title);
2261      free(old_title);
22622262      return TRUE;
22632263   }
22642264   
r7842r7843
22722272   if (retval)
22732273   {
22742274      TryRenameCustomFolderIni(lpFolder, lpFolder->m_lpTitle, new_name);
2275      global_free(lpFolder->m_lpTitle);
2275      free(lpFolder->m_lpTitle);
22762276      lpFolder->m_lpTitle = (char *)malloc(strlen(new_name) + 1);
22772277      strcpy(lpFolder->m_lpTitle,new_name);
22782278   }
src/osd/winui/winui.c
r7842r7843
10181018      /* free arguments */
10191019      for (i = 0; i < __argc; i++)
10201020         global_free(utf8_argv[i]);
1021      global_free(utf8_argv);
1021      free(utf8_argv);
10221022     
10231023      exit(rc);
10241024   }
r7842r7843
12251225                     {
12261226                        hIcon = FormatICOInMemoryToHICON(bufferPtr, entry->uncompressed_length);
12271227                     }
1228                     global_free(bufferPtr);
1228                     free(bufferPtr);
12291229                  }
12301230               }
12311231               entry = zip_file_next_file(zip);
r7842r7843
16851685      ResetBackground(szFile);
16861686   }
16871687
1688   global_free(buf);
1688   free(buf);
16891689}
16901690
16911691static void SetMainTitle(void)
r7842r7843
34043404   {
34053405      TV_DISPINFO *ptvdi = (TV_DISPINFO *)nm;
34063406      LPTREEFOLDER folder = (LPTREEFOLDER)ptvdi->item.lParam;
3407      char* szText;
3407      char* utf8_szText;
34083408      BOOL result;
34093409
34103410      g_in_treeview_edit = FALSE;
r7842r7843
34123412      if (ptvdi->item.pszText == NULL || _tcslen(ptvdi->item.pszText) == 0)
34133413         return FALSE;
34143414
3415      szText = utf8_from_tstring(ptvdi->item.pszText);
3416      if( !szText )
3415      utf8_szText = utf8_from_tstring(ptvdi->item.pszText);
3416      if( !utf8_szText )
34173417         return FALSE;
34183418
3419      result = TryRenameCustomFolder(folder,szText);
3419      result = TryRenameCustomFolder(folder, utf8_szText);
34203420
3421      global_free(szText);
3421      global_free(utf8_szText);
34223422
34233423      return result;
34243424   }
src/osd/winui/properties.c
r7842r7843
489489      win_message_box_utf8(0, temp, "Error", IDOK);
490490   }
491491
492   global_free(pspage);
492   free(pspage);
493493}
494494
495495/* Initilize the property pages for anything but the Default option set */
r7842r7843
608608   }
609609
610610   global_free(t_description);
611   global_free(pspage);
611   free(pspage);
612612}
613613
614614
r7842r7843
21022102   int selected = 0;
21032103   int index = 0;
21042104   LPCTSTR t_ctrlr_option = 0;
2105   LPTSTR buf = 0;
2105   LPTSTR t_buf = 0;
21062106   const char *ctrlr_option;
21072107   TCHAR* t_ctrldir;
21082108
r7842r7843
21102110   ctrlr_option = options_get_string(opts, OPTION_CTRLR);
21112111   if( ctrlr_option != NULL )
21122112   {
2113      buf = tstring_from_utf8(ctrlr_option);
2114      if( !buf )
2113      t_buf = tstring_from_utf8(ctrlr_option);
2114      if( !t_buf )
21152115         return FALSE;
2116      t_ctrlr_option = buf;
2116      t_ctrlr_option = t_buf;
21172117   }
21182118   else
21192119   {
r7842r7843
21292129   t_ctrldir = tstring_from_utf8(GetCtrlrDir());
21302130   if( !t_ctrldir )
21312131   {
2132      if( buf )
2133         global_free(buf);
2132      if( t_buf )
2133         global_free(t_buf);
21342134      return FALSE;
21352135   }
21362136
r7842r7843
21752175
21762176   (void)ComboBox_SetCurSel(control, selected);
21772177   
2178   if( buf )
2179      global_free(buf);
2178   if( t_buf )
2179      global_free(t_buf);
21802180
21812181   return FALSE;
21822182}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team