Changeset 335 for trunk/dll/seeall.c


Ignore:
Timestamp:
Jul 25, 2006, 9:03:44 PM (19 years ago)
Author:
root
Message:

Use Runtime_Error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/seeall.c

    r302 r335  
    1717  06 Jun 05 SHL Drop unused code
    1818  29 May 06 SHL Comments
     19  17 Jul 06 SHL Use Runtime_Error
    1920
    2021***********************************************************************/
     
    3839
    3940#pragma data_seg(DATA2)
     41
     42static PSZ pszSrcFile = __FILE__;
     43
    4044#pragma alloc_text(SEEALL,comparefullnames,comparenames,comparesizes)
    4145#pragma alloc_text(SEEALL,comparedates,compareexts,SeeStatusProc)
     
    206210                flags |= (DP_CRCS | DP_SIZES);
    207211            }
    208             if(!flags)
     212            if (!flags)
    209213              saymsg(MB_ENTER,
    210214                     hwnd,
     
    380384              LISTINFO *li;
    381385
    382               li = malloc(sizeof(LISTINFO));
    383               if(li) {
    384                 memset(li,0,sizeof(LISTINFO));
     386              li = xmallocz(sizeof(LISTINFO),pszSrcFile,__LINE__);
     387              if (li) {
    385388                li->hwndS = WinWindowFromID(hwndFrame,FID_CLIENT);
    386389                li->type = IDM_PRINT;
     
    394397                  if(li && li->list && li->list[0]) {
    395398                    strcpy(li->targetpath,printer);
    396                     if(_beginthread(PrintList,
    397                                     NULL,
    398                                     65536,
    399                                     (PVOID)li) == -1) {
    400                       DosBeep(50,100);
     399                    if(_beginthread(PrintList,NULL,65536,(PVOID)li) == -1) {
     400                      Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
    401401                      FreeListInfo(li);
    402402                    }
     
    404404                }
    405405              }
    406               else
    407                 FreeList(list);
    408406            }
    409407            break;
     
    842840                                   rc,
    843841                                   hwndFrame,
    844                                    __FILE__,
     842                                   pszSrcFile,
    845843                                   __LINE__,
    846844                                   "%s %s \"%s\" %s\"%s\" %s.",
     
    913911                 !*ex.extractdir)
    914912                break;
    915               if(!IsFile(ex.extractdir)) {
     913              if (IsFile(ex.extractdir) != 0)
     914                Runtime_Error(pszSrcFile, __LINE__, "directory expected");
     915              else {
    916916                if(needs_quoting(ex.masks) &&
    917917                   !strchr(ex.masks,'\"') )
     
    930930                        (maskspaces) ? "\"" : NullStr);
    931931              }
    932               else
    933                 DosBeep(50,100);
    934             }
    935             if(!PostMsg(WinWindowFromID(hwndFrame,FID_CLIENT),
    936                         UM_UPDATERECORDLIST,
    937                         MPFROMP(list),
    938                         MPVOID))
     932            }
     933            // fixme to not leak?
     934            if (!PostMsg(WinWindowFromID(hwndFrame,FID_CLIENT),
     935                         UM_UPDATERECORDLIST,
     936                         MPFROMP(list),
     937                         MPVOID))
    939938              FreeList(list);
    940939            break;
     
    11371136                               error,
    11381137                               hwndFrame,
    1139                                __FILE__,
     1138                               pszSrcFile,
    11401139                               __LINE__,
    11411140                               GetPString(IDS_DELETEFAILED2TEXT),
     
    16121611              ALLFILES *temp,**templ;
    16131612
    1614               temp = realloc(ad->afhead,(ad->afalloc + 1) *
    1615                              sizeof(ALLFILES));
    1616               if(temp) {
    1617                 ad->afhead = temp;
    1618                 templ = realloc(ad->afindex,(ad->afalloc + 1) *
    1619                                 sizeof(ALLFILES *));
    1620                 if(templ)
    1621                   ad->afindex = templ;
    1622                 else {
    1623                   // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Realloc failed.");
    1624                   ad->stopflag = 1;
    1625                   break;
    1626                 }
    1627                 ad->afalloc++;
    1628               }
    1629               else {
    1630                 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Realloc failed.");
     1613              temp = xrealloc(ad->afhead,(ad->afalloc + 1) * sizeof(ALLFILES),pszSrcFile,__LINE__);
     1614              if (!temp) {
    16311615                ad->stopflag = 1;
    16321616                break;
    16331617              }
    1634             }
    1635             ad->afhead[ad->affiles].fullname   = strdup(list[z]);
     1618              else {
     1619                ad->afhead = temp;
     1620                templ = xrealloc(ad->afindex,(ad->afalloc + 1) * sizeof(ALLFILES *),pszSrcFile,__LINE__);
     1621                if (!templ) {
     1622                  ad->stopflag = 1;
     1623                  break;
     1624                }
     1625                else
     1626                  ad->afindex = templ;
     1627                ad->afalloc++;
     1628              }
     1629            }
     1630            ad->afhead[ad->affiles].fullname   = xstrdup(list[z],pszSrcFile,__LINE__);
    16361631            if(ad->afhead[ad->affiles].fullname) {
    16371632              p = strrchr(ad->afhead[ad->affiles].fullname,'\\');
     
    20082003      FreeAllFilesList(hwnd);
    20092004    else {
    2010       tempa = realloc(pAD->afhead,pAD->affiles * sizeof(ALLFILES));
    2011       if(tempa) {
     2005      tempa = xrealloc(pAD->afhead,pAD->affiles * sizeof(ALLFILES),pszSrcFile,__LINE__);
     2006      if (tempa) {
    20122007        pAD->afhead = tempa;
    20132008        pAD->afalloc = pAD->affiles;
    20142009      }
    2015       templ = realloc(pAD->afindex,pAD->affiles * sizeof(ALLFILES *));
    2016       if(templ)
     2010      templ = xrealloc(pAD->afindex,pAD->affiles * sizeof(ALLFILES *),pszSrcFile,__LINE__);
     2011      if (templ)
    20172012        pAD->afindex = templ;
    20182013      DosPostEventSem(CompactSem);
     
    20342029  register PBYTE fb;
    20352030
    2036   filename = malloc(CCHMAXPATH);
    2037   if(!filename) {
    2038     // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Malloc filename failed.");
     2031  filename = xmalloc(CCHMAXPATH,pszSrcFile,__LINE__);
     2032  if(!filename)
    20392033    return;
    2040   }
     2034
    20412035  uL = ad->afFilesToGet;
    20422036  if(fRemoteBug && isalpha(*pathname) && pathname[1] == ':' &&
     
    20442038     (driveflags[toupper(*pathname) - 'A'] & DRIVE_REMOTE))
    20452039    uL = 1L;
    2046   pffb = malloc(sizeof(FILEFINDBUF3) * uL);
     2040  pffb = xmalloc(sizeof(FILEFINDBUF3) * uL,pszSrcFile,__LINE__);
    20472041  if(!pffb) {
    20482042    free(filename);
    2049     // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Malloc pffb failed.");
    20502043    return;
    20512044  }
     
    20832076            ALLFILES *temp;
    20842077
    2085             temp = realloc(ad->afhead,(ad->afalloc + 1000) *
    2086                            sizeof(ALLFILES));
    2087             if(temp) {
     2078            temp = xrealloc(ad->afhead,(ad->afalloc + 1000) *
     2079                           sizeof(ALLFILES),pszSrcFile,__LINE__);
     2080            if (!temp) {
     2081              ad->stopflag = 1;
     2082              break;
     2083            }
     2084            else {
    20882085              ad->afhead = temp;
    20892086              if(ad->stopflag)
     
    20912088              ad->afalloc += 1000;
    20922089            }
    2093             else {
    2094               // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Realloc failed.");
    2095               ad->stopflag = 1;
    2096               break;
    2097             }
    2098           }
    2099           ad->afhead[ad->affiles].fullname   = strdup(filename);
    2100           if(ad->afhead[ad->affiles].fullname) {
     2090          }
     2091          ad->afhead[ad->affiles].fullname   = xstrdup(filename,pszSrcFile,__LINE__);
     2092          if (!ad->afhead[ad->affiles].fullname) {
     2093            ad->stopflag = 1;
     2094            break;
     2095          }
     2096          else {
    21012097            ad->afhead[ad->affiles].filename =
    21022098              ad->afhead[ad->affiles].fullname + (enddir - filename);
     
    21112107            if(ad->longestw < ffb->cchName + (enddir - filename))
    21122108              ad->longestw = ffb->cchName + (enddir - filename);
    2113           }
    2114           else {
    2115             // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"Strdup failed.");
    2116             ad->stopflag = 1;
    2117             break;
    21182109          }
    21192110        }
     
    21742165      ALLFILES *tempa,**templ;
    21752166
    2176       tempa = realloc(ad->afhead,sizeof(ALLFILES) * ad->affiles);
    2177       if(tempa) {
     2167      tempa = xrealloc(ad->afhead,sizeof(ALLFILES) * ad->affiles,pszSrcFile,__LINE__);
     2168      if (tempa) {
    21782169        ad->afhead = tempa;
    21792170        ad->afalloc = ad->affiles;
    21802171      }
    2181       templ = realloc(ad->afindex,sizeof(ALLFILES *) * ad->affiles);
    2182       if(templ)
     2172      templ = xrealloc(ad->afindex,sizeof(ALLFILES *) * ad->affiles,pszSrcFile,__LINE__);
     2173      if (templ)
    21832174        ad->afindex = templ;
    21842175      DosPostEventSem(CompactSem);
    21852176    }
    21862177
    2187     if(!ad->stopflag) {
     2178    if (!ad->stopflag) {
    21882179      PostMsg(hwnd,UM_RESCAN,MPFROMLONG(1L),MPVOID);
    21892180      ReSort(hwnd);
     
    25522543      // fprintf(stderr,"Seeall: WM_CREATE\n");
    25532544      WinSetWindowPtr(hwnd,QWL_USER,NULL);
    2554       pAD = malloc(sizeof(ALLDATA));
     2545      pAD = xmallocz(sizeof(ALLDATA),pszSrcFile,__LINE__);
    25552546      if(pAD) {
    2556         memset(pAD,0,sizeof(ALLDATA));
    25572547        pAD->size = sizeof(ALLDATA);
    25582548        pAD->hwndFrame = WinQueryWindow(hwnd,QW_PARENT);
     
    26612651                                       FID_HORZSCROLL);
    26622652        pAD->multiplier = 1;
    2663         if(_beginthread(MakeSeeObj,NULL,122880,(PVOID)pAD) != -1) {
    2664           if(!DosCreateMutexSem(NULL,&pAD->hmtxScan,0L,FALSE)) {
     2653        if(_beginthread(MakeSeeObj,NULL,122880,(PVOID)pAD) == -1)
     2654          Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
     2655        else {
     2656          if (!DosCreateMutexSem(NULL,&pAD->hmtxScan,0L,FALSE)) {
    26652657            pAD->hwndStatus = WinCreateWindow(WinQueryWindow(hwnd,QW_PARENT),
    26662658                                              GetPString(IDS_WCSEESTATUS),
     
    27062698          }
    27072699        }
    2708         if(_beginthread(FindAllThread,NULL,524288,(PVOID)hwnd) == -1)
     2700        if(_beginthread(FindAllThread,NULL,524288,(PVOID)hwnd) == -1) {
     2701          Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
    27092702          PostMsg(hwnd,WM_CLOSE,MPVOID,MPVOID);
     2703        }
    27102704        else {
    27112705          DosSleep(100L);
     
    28382832            strcpy(s,
    28392833                   GetPString(IDS_WORKINGTEXT));
    2840             if(pAD->affiles) {
     2834            if (pAD->affiles) {
    28412835              commafmt(tm,sizeof(tm),pAD->affiles);
    28422836              strcat(s,tm);
     
    31583152
    31593153        list = BuildAList(hwnd);
    3160         if(list) {
     3154        if (!list)
     3155          Runtime_Error(pszSrcFile, __LINE__, "no data");
     3156        else {
    31613157          WinSetWindowText(pAD->hwndStatus,
    31623158                           GetPString(IDS_DRAGGINGFILESTEXT));
     
    31713167                  MPVOID);
    31723168        }
    3173         else
    3174           DosBeep(50,100);
    31753169      }
    31763170      break;
     
    39613955                                              DUPE_FRAME,
    39623956                                              MPFROM2SHORT(pAD->dupeflags,0));
    3963             if(pAD->dupeflags) {
    3964               if(_beginthread(FindDupes,
    3965                               NULL,
    3966                               65536,
    3967                               (PVOID)hwnd) == -1)
    3968                 DosBeep(50,100);
     3957            if (pAD->dupeflags) {
     3958              if(_beginthread(FindDupes,NULL,65536,(PVOID)hwnd) == -1)
     3959                Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
    39693960            }
    39703961            DosReleaseMutexSem(pAD->hmtxScan);
     
    41604151            FreeAllFilesList(hwnd);
    41614152            pAD->stopflag = 0;
    4162             if(_beginthread(FindAllThread,NULL,524288,(PVOID)hwnd) != -1) {
     4153            if(_beginthread(FindAllThread,NULL,524288,(PVOID)hwnd) == -1) {
     4154              Runtime_Error(pszSrcFile, __LINE__, GetPString(IDS_COULDNTSTARTTHREADTEXT));
     4155              WinDestroyWindow(WinQueryWindow(hwnd,QW_PARENT));
     4156              DosReleaseMutexSem(pAD->hmtxScan);
     4157            }
     4158            else {
    41634159              DosReleaseMutexSem(pAD->hmtxScan);
    41644160              DosSleep(100);
     
    41664162              PostMsg(hwnd,UM_SETUP2,MPVOID,MPVOID);
    41674163              PostMsg(hwnd,UM_RESCAN,MPVOID,MPVOID);
    4168             }
    4169             else {
    4170               DosBeep(250,100);
    4171               WinDestroyWindow(WinQueryWindow(hwnd,QW_PARENT));
    4172               DosReleaseMutexSem(pAD->hmtxScan);
    41734164            }
    41744165          }
     
    42654256                  CHAR **list = BuildAList(hwnd);
    42664257
    4267                   if(list) {
     4258                  if (!list)
     4259                    Runtime_Error(pszSrcFile, __LINE__, "no data");
     4260                  else {
    42684261                    switch(SHORT1FROMMP(mp1)) {
    42694262                      case IDM_COLLECT:
     
    43044297                    }
    43054298                  }
    4306                   else
    4307                     DosBeep(50,100);
    43084299                }
    43094300                break;
     
    44384429                   UM_SETUP4,
    44394430                   MPVOID,
    4440                    MPVOID)) 
     4431                   MPVOID))
    44414432      {
    44424433        PostMsg((HWND)0,
     
    44514442      // Needs to be static for other thread
    44524443      if (!pszDir)
    4453           pszDir = malloc(CCHMAXPATH);
     4444          pszDir = xmalloc(CCHMAXPATH,pszSrcFile,__LINE__);
    44544445      if (pszDir) {
    44554446        strcpy(pszDir, pszStartPath);
Note: See TracChangeset for help on using the changeset viewer.