Changeset 1335 for trunk/dll/dirsize.c


Ignore:
Timestamp:
Dec 13, 2008, 12:49:02 AM (17 years ago)
Author:
Steven Levine
Message:

Ticket 26: Add exception handlers to all threads using xbeginthread

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/dirsize.c

    r1321 r1335  
    3535  07 Jul 08 GKY Fixed trap in PMCTLS (strlen) inadequate memory allocation
    3636  07 Jul 08 GKY Fixed trap by no longer allocating pci->pszLongName as flag but pointing isroot
    37                 version to NullStr and all others to NULL.
     37                version to NullStr and all others to NULL.
    3838  19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory; use pTmpDir for temp files
    3939  03 Aug 08 GKY Reworked FillInRecSizes to use pci->pszDisplayName for display names and
    40                 created a more consitent string for passing to DRAWITEM. Finally (I hope) fixed
    41                 the strlen trap.
     40                created a more consitent string for passing to DRAWITEM. Finally (I hope) fixed
     41                the strlen trap.
    4242  23 Aug 08 GKY Fix memory leak (failure to free cnritems)
     43  10 Dec 08 SHL Integrate exception handler support
    4344
    4445***********************************************************************/
     
    4748#include <string.h>
    4849#include <ctype.h>
    49 #include <process.h>                    // _beginthread
     50// #include <process.h>                 // _beginthread
    5051
    5152#define INCL_DOS
     
    8081#include "misc.h"                       // PostMsg
    8182#include "fortify.h"
     83#include "excputil.h"                   // xbeginthread
    8284
    8385typedef struct
     
    142144  /*if (!stricmp(FileSystem, NTFS)) {
    143145    saymsg(MB_OK,
    144            HWND_DESKTOP,
    145            NullStr,
    146            GetPString(IDS_NTFSDRIVERFAILSTEXT));
     146           HWND_DESKTOP,
     147           NullStr,
     148           GetPString(IDS_NTFSDRIVERFAILSTEXT));
    147149    return FALSE;
    148150  } */
     
    343345      if (isroot) {
    344346        FSALLOCATE fsa;
    345         APIRET rc;
    346 
    347 
    348         memset(&fsa, 0, sizeof(fsa));
     347        APIRET rc;
     348
     349
     350        memset(&fsa, 0, sizeof(fsa));
    349351        rc = DosQueryFSInfo(toupper(*pci->pszFileName) - '@', FSIL_ALLOC, &fsa,
    350352                            sizeof(FSALLOCATE));
     
    353355            ((float)fsa.cUnit * (fsa.cSectorUnit * fsa.cbSector));
    354356        }
    355         // Need unique buffer 23 Jul 07 SHL
    356         pci->pszLongName = NullStr;
     357        // Need unique buffer 23 Jul 07 SHL
     358        pci->pszLongName = NullStr;
    357359      }
    358360      else
     
    363365      cBar = (UINT) fltPct / 2;
    364366      if (cBar && cBar * 2 != (UINT) fltPct)
    365         szBar[cBar] = '=';
     367        szBar[cBar] = '=';
    366368      szBar[100] = 0;
    367369    }
     
    378380            fltPct,
    379381            isroot ? GetPString(IDS_OFDRIVETEXT) : NullStr,
    380             szBar);
     382            szBar);
    381383    pci->pszDisplayName = xstrdup(szBuf, pszSrcFile, __LINE__);
    382384    // use DisplayName for display hopefully fixes "strlen" trap 02 AUG 08 GKY
     
    393395    attrib = CMA_FIRST;
    394396  pci = (PCNRITEM) WinSendMsg(hwndCnr, CM_QUERYRECORD, MPFROMP(pci),
    395                               MPFROM2SHORT(attrib, CMA_ITEMORDER));
     397                              MPFROM2SHORT(attrib, CMA_ITEMORDER));
    396398  while (pci && (INT) pci != -1) {
    397399    if (*pchStopFlag)
     
    525527      PrfQueryProfileData(fmprof, FM3Str, "DirSizes.Position", (PVOID) &swp, &size);
    526528      WinSetWindowPos(hwnd,
    527                       HWND_TOP,
    528                       swp.x,
    529                       swp.y,
    530                       swp.cx,
    531                       swp.cy,
    532                       swp.fl);
     529                      HWND_TOP,
     530                      swp.x,
     531                      swp.y,
     532                      swp.cx,
     533                      swp.cy,
     534                      swp.fl);
    533535    }
    534536    {
     
    543545      dirsize->pszFileName = pState->szDirName;
    544546      dirsize->hwndCnr = WinWindowFromID(hwnd, DSZ_CNR);
    545       if (_beginthread(FillCnrThread, NULL, 122880L * 5, (PVOID)dirsize) ==
    546           -1) {
    547         Runtime_Error(pszSrcFile, __LINE__,
    548                       GetPString(IDS_COULDNTSTARTTHREADTEXT));
     547      if (xbeginthread(FillCnrThread,
     548                       122880 * 5,
     549                       dirsize,
     550                       pszSrcFile,
     551                       __LINE__) == -1)
     552      {
    549553        xfree(dirsize, pszSrcFile, __LINE__);
    550554        WinDismissDlg(hwnd, 0);
     
    687691            p = strchr(pci->pszDisplayName, '\r');
    688692            if (p) {
    689               // draw text
    690               if (pci->pszLongName == NullStr)  // is root record
    691                 GpiSetColor(oi->hps, CLR_DARKRED);
     693              // draw text
     694              if (pci->pszLongName == NullStr)  // is root record
     695                GpiSetColor(oi->hps, CLR_DARKRED);
    692696              else if (!pci->cbFile)            // no size
    693697                GpiSetColor(oi->hps, CLR_DARKGRAY);
     
    826830                switch (x) {
    827831                case 1:
    828                 case 3:
    829                 case 5:
     832                case 3:
     833                case 5:
    830834                case 7:
    831                 case 9:
    832                 case 11:
    833                 case 13:
    834                 case 15:
    835                 case 17:
    836                 case 19:
     835                case 9:
     836                case 11:
     837                case 13:
     838                case 15:
     839                case 17:
     840                case 19:
    837841                  ptl.y -= 1;
    838842                  break;
     
    843847                case 4:
    844848                case 6:
    845                 case 8:
    846                 case 12:
    847                 case 14:
    848                 case 16:
    849                 case 18:
     849                case 8:
     850                case 12:
     851                case 14:
     852                case 16:
     853                case 18:
    850854                  ptl.y -= 2;
    851855                  break;
     
    854858              } // for x
    855859              return MRFROMLONG(TRUE);
    856             }
     860            }
    857861          }
    858862        }
     
    948952        FILE *fp;
    949953
    950         if (pTmpDir)
    951           strcpy(szFileName, pTmpDir);
    952         else
    953           strcpy(szFileName, pFM2SaveDirectory);
     954        if (pTmpDir)
     955          strcpy(szFileName, pTmpDir);
     956        else
     957          strcpy(szFileName, pFM2SaveDirectory);
    954958        sprintf(&szFileName[strlen(szFileName)], "\\%csizes.Rpt",
    955959                (pState) ? toupper(*pState->szDirName) : '+');
     
    10071011    case DID_CANCEL:
    10081012      {
    1009         SWP swp;
    1010         ULONG size = sizeof(SWP);
    1011 
    1012         WinQueryWindowPos(hwnd, &swp);
    1013         PrfWriteProfileData(fmprof, FM3Str, "DirSizes.Position", (PVOID) &swp,
    1014                             size);
     1013        SWP swp;
     1014        ULONG size = sizeof(SWP);
     1015
     1016        WinQueryWindowPos(hwnd, &swp);
     1017        PrfWriteProfileData(fmprof, FM3Str, "DirSizes.Position", (PVOID) &swp,
     1018                            size);
    10151019      }
    10161020      pState = INSTDATA(hwnd);
Note: See TracChangeset for help on using the changeset viewer.