Changeset 91 for trunk/src


Ignore:
Timestamp:
Aug 2, 2001, 10:36:35 PM (24 years ago)
Author:
umoeller
Message:

Misc changes

Location:
trunk/src/helpers
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/apps.c

    r78 r91  
    210210        {
    211211            PSZ     *ppszThis = pEnv->papszVars;
    212             PSZ     pszThis;
     212            // PSZ     pszThis;
    213213            ULONG   ul = 0;
    214214            ULONG   ulVarNameLen = 0;
     
    233233                 ul++)
    234234            {
    235                 pszThis = *ppszThis;
    236 
    237235                if (strnicmp(*ppszThis, pszSearch, ulVarNameLen) == 0)
    238236                {
  • trunk/src/helpers/cctl_chart.c

    r68 r91  
    423423    {
    424424        HRGN        hrgnThis;
    425         SHORT       sSweepAngle,
    426                     sStartAngle;
     425        /* SHORT       sSweepAngle,
     426                    sStartAngle; */
    427427
    428428        GpiSetCurrentPosition(hpsMem, &ptlLowerLeft);
     
    14571457                       LONG ly)
    14581458{
    1459     LONG lRegionFound = -1; // none
     1459    // LONG lRegionFound = -1; // none
    14601460
    14611461    POINTL ptlMouse = {lx, ly};
  • trunk/src/helpers/cctl_tooltip.c

    r82 r91  
    12241224
    12251225        POINTL      ptlPointer;
    1226         HPS         hps;
     1226        // HPS         hps;
    12271227
    12281228        // free old text
  • trunk/src/helpers/comctl.c

    r81 r91  
    310310 *@@added V0.9.0 [umoeller]
    311311 *@@changed V0.9.2 (2000-02-28) [umoeller]: menu was displayed even if button was disabled; fixed
     312 *@@changed V0.9.14 (2001-07-31) [umoeller]: fixed WM_MENUEND submenu quirk
    312313 */
    313314
     
    486487        case WM_MENUEND:
    487488        {
    488             BOOL fUnHilite = TRUE;
    489             // _Pmpf(("WM_MENUEND"));
    490             // At this point, the menu has been
    491             // destroyed already.
    492             // Since WM_BUTTON1UP handles the
    493             // default case that the user presses
    494             // the menu button a second time while
    495             // the menu is open, we only need
    496             // to handle the case that the user
    497             // c)   presses some key on the menu (ESC, menu selection) or
    498             // a)   selects a menu item (which
    499             //      dismisses the menu) or
    500             // b)   clicks anywhere else.
    501 
    502             // Case a) if mouse button 1 is not currently down
    503             if ((WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000) == 0)
    504                 // button 1 _not_ down:
    505                 // must be keyboard
    506                 fUnHilite = TRUE;
    507             else
    508                 // button 1 _is_ down:
    509                 // query window under mouse pointer
    510                 ;
    511 
    512             if (fUnHilite)
     489            if ((HWND)mp2 == pmbd->hwndMenu) // V0.9.14 (2001-07-31) [umoeller]
    513490            {
    514                 // _Pmpf(("  Unsinking menu WM_MENUEND"));
    515                 pmbd->fButtonSunk = FALSE;
    516                 WinSendMsg(hwndButton,
    517                            BM_SETHILITE,
    518                            (MPARAM)FALSE,
    519                            (MPARAM)0);
    520             }
    521             pmbd->hwndMenu = NULLHANDLE;
     491                BOOL fUnHilite = TRUE;
     492                // _Pmpf(("WM_MENUEND"));
     493                // At this point, the menu has been
     494                // destroyed already.
     495                // Since WM_BUTTON1UP handles the
     496                // default case that the user presses
     497                // the menu button a second time while
     498                // the menu is open, we only need
     499                // to handle the case that the user
     500                // c)   presses some key on the menu (ESC, menu selection) or
     501                // a)   selects a menu item (which
     502                //      dismisses the menu) or
     503                // b)   clicks anywhere else.
     504
     505                // Case a) if mouse button 1 is not currently down
     506                if ((WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000) == 0)
     507                    // button 1 _not_ down:
     508                    // must be keyboard
     509                    fUnHilite = TRUE;
     510                else
     511                    // button 1 _is_ down:
     512                    // query window under mouse pointer
     513                    ;
     514
     515                if (fUnHilite)
     516                {
     517                    // _Pmpf(("  Unsinking menu WM_MENUEND"));
     518                    pmbd->fButtonSunk = FALSE;
     519                    WinSendMsg(hwndButton,
     520                               BM_SETHILITE,
     521                               (MPARAM)FALSE,
     522                               (MPARAM)0);
     523                }
     524                pmbd->hwndMenu = NULLHANDLE;
     525            } // end if ((HWND)mp1 == pmbd->pmbd->hwndMenu) // V0.9.14 (2001-07-31) [umoeller]
    522526        break; }
    523527
  • trunk/src/helpers/configsys.c

    r71 r91  
    378378    {
    379379        // key found in file:
    380         ULONG   ulOfs;
     380        // ULONG   ulOfs;
    381381
    382382        // replace existing parameter
  • trunk/src/helpers/dialog.c

    r89 r91  
    110110    const char  *pcszControlsFont;  // from dlghCreateDlg
    111111
     112    // V0.9.14 (2001-08-01) [umoeller]
    112113    HPS         hps;
    113     /* const char  *pcszFontLast;
    114     LONG        lcidLast; */
     114    const char  *pcszFontLast;
     115    LONG        lcidLast;
     116    FONTMETRICS fmLast;
     117
    115118} DLGPRIVATE, *PDLGPRIVATE;
    116119
     
    148151    BOOL        fIsNestedTable;     // if TRUE, pvDefinition points to a nested TABLEDEF;
    149152                                    // if FALSE, pvDefinition points to a CONTROLDEF as
    150                                     // specified by the user
     153                                    // specified by the caller
    151154
    152155    PVOID       pvDefinition;       // either a PTABLEDEF or a PCONTROLDEF
     
    225228 *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed various things with statics
    226229 *@@changed V0.9.12 (2001-05-31) [umoeller]: fixed broken fonts
     230 *@@changed V0.9.14 (2001-08-01) [umoeller]: now caching fonts, which is significantly faster
    227231 */
    228232
     
    232236                      PDLGPRIVATE pDlgData)
    233237{
    234     BOOL        fFind = FALSE;
    235     RECTL       rclText;
    236     LONG        lcid = 0;
    237 
    238238    const char *pcszFontThis = pControlDef->pcszFont;
    239239                    // can be NULL,
     
    248248    if (pcszFontThis)
    249249    {
    250         FONTMETRICS fm;
    251250        LONG lPointSize = 0;
    252251
    253         // create new font
    254         lcid = gpihFindPresFont(NULLHANDLE,        // no window yet
    255                                 FALSE,
    256                                 pDlgData->hps,
    257                                 pcszFontThis,
    258                                 &fm,
    259                                 &lPointSize);
    260         GpiSetCharSet(pDlgData->hps, lcid);
    261         if (fm.fsDefn & FM_DEFN_OUTLINE)
    262             gpihSetPointSize(pDlgData->hps, lPointSize);
    263 
    264         pszlAuto->cy = fm.lMaxBaselineExt + fm.lExternalLeading;
     252        // check if we can reuse font data from last time
     253        // V0.9.14 (2001-08-01) [umoeller]
     254        if (strhcmp(pcszFontThis,
     255                    pDlgData->pcszFontLast))
     256        {
     257            // different font than last time:
     258
     259            // delete old font?
     260            if (pDlgData->lcidLast)
     261            {
     262                GpiSetCharSet(pDlgData->hps, LCID_DEFAULT);
     263                GpiDeleteSetId(pDlgData->hps, pDlgData->lcidLast);
     264            }
     265
     266            // create new font
     267            pDlgData->lcidLast = gpihFindPresFont(NULLHANDLE,        // no window yet
     268                                                  FALSE,
     269                                                  pDlgData->hps,
     270                                                  pcszFontThis,
     271                                                  &pDlgData->fmLast,
     272                                                  &lPointSize);
     273
     274            GpiSetCharSet(pDlgData->hps, pDlgData->lcidLast);
     275            if (pDlgData->fmLast.fsDefn & FM_DEFN_OUTLINE)
     276                gpihSetPointSize(pDlgData->hps, lPointSize);
     277
     278            pDlgData->pcszFontLast = pcszFontThis;
     279        }
     280
     281        pszlAuto->cy =   pDlgData->fmLast.lMaxBaselineExt
     282                       + pDlgData->fmLast.lExternalLeading;
    265283    }
    266284
     
    300318        }
    301319    }
    302 
    303     /* if (lcid)
    304     {
    305         GpiSetCharSet(pDlgData->hps, LCID_DEFAULT);
    306         GpiDeleteSetId(pDlgData->hps, lcid);
    307     } */
    308 
    309320}
    310321
     
    336347                                        | BS_CHECKBOX
    337348                                        | BS_RADIOBUTTON))
     349            {
     350                // give a little extra width for the box bitmap
    338351                pszlAuto->cx += 20;     // @@todo
     352                // and height
     353                pszlAuto->cy += 2;
     354            }
    339355            else if (pControlDef->flStyle & BS_BITMAP)
    340356                ;
     
    722738                PDLGPRIVATE pDlgData)
    723739{
    724     ULONG   ul;
     740    // ULONG   ul;
    725741    LONG    lX;
    726742    PLISTNODE pNode;
     
    791807                  PDLGPRIVATE pDlgData)
    792808{
    793     ULONG   ul;
     809    // ULONG   ul;
    794810    LONG    lY;
    795811    PLISTNODE pNode;
     
    864880                PROCESSMODE ProcessMode)
    865881{
    866     ULONG ul;
     882    // ULONG ul;
    867883    PLISTNODE pNode;
    868884    CONTROLPOS cpTable;
     
    943959
    944960    return (arc);
     961}
     962
     963/*
     964 *@@ FreeTable:
     965 *      frees the specified table and recurses
     966 *      into nested tables, if necessary.
     967 *
     968 *      This was added with V0.9.14 to fix the
     969 *      bad memory leaks with nested tables.
     970 *
     971 *@@added V0.9.14 (2001-08-01) [umoeller]
     972 */
     973
     974VOID FreeTable(PTABLEDEF pTable)
     975{
     976    // for each table, clean up the rows
     977    PLISTNODE pRowNode;
     978    FOR_ALL_NODES(&pTable->llRows, pRowNode)
     979    {
     980        PROWDEF pRow = (PROWDEF)pRowNode->pItemData;
     981
     982        // for each row, clean up the columns
     983        PLISTNODE pColumnNode;
     984        FOR_ALL_NODES(&pRow->llColumns, pColumnNode)
     985        {
     986            PCOLUMNDEF pColumn = (PCOLUMNDEF)pColumnNode->pItemData;
     987
     988            if (pColumn->fIsNestedTable)
     989            {
     990                // nested table: recurse!
     991                PTABLEDEF pNestedTable = (PTABLEDEF)pColumn->pvDefinition;
     992                FreeTable(pNestedTable);
     993            }
     994
     995            free(pColumn);
     996        }
     997        lstClear(&pRow->llColumns);
     998
     999        free(pRow);
     1000    }
     1001    lstClear(&pTable->llRows);
     1002
     1003    free(pTable);
    9451004}
    9461005
     
    11811240 *
    11821241 *@@changed V0.9.14 (2001-07-07) [umoeller]: fixed disabled mouse with hwndOwner == HWND_DESKTOP
     1242 *@@changed V0.9.14 (2001-08-01) [umoeller]: fixed major memory leaks with nested tables
    11831243 */
    11841244
     
    12701330                        // create "table" column for this
    12711331                        PCOLUMNDEF pColumnDef;
    1272                         arc = CreateColumn(pCurrentRow,
    1273                                            TRUE,        // nested table
    1274                                            pCurrentTable,
    1275                                            &pColumnDef);
    1276                         if (!arc)
    1277                             lstAppendItem(&pCurrentRow->llColumns, pColumnDef);
     1332                        if (!(arc = CreateColumn(pCurrentRow,
     1333                                                 TRUE,        // nested table
     1334                                                 pCurrentTable,
     1335                                                 &pColumnDef)))
     1336                            lstAppendItem(&pCurrentRow->llColumns,
     1337                                          pColumnDef);
    12781338                    }
    12791339                }
     
    13191379            {
    13201380                PCOLUMNDEF pColumnDef;
    1321                 arc = CreateColumn(pCurrentRow,
    1322                                    FALSE,        // no nested table
    1323                                    (PVOID)pItemThis->ulData,
    1324                                    &pColumnDef);
    1325                 if (!arc)
    1326                     lstAppendItem(&pCurrentRow->llColumns, pColumnDef);
     1381                if (!(arc = CreateColumn(pCurrentRow,
     1382                                         FALSE,        // no nested table
     1383                                         (PVOID)pItemThis->ulData,
     1384                                         &pColumnDef)))
     1385                    lstAppendItem(&pCurrentRow->llColumns,
     1386                                  pColumnDef);
    13271387            break; }
    13281388
     
    14161476                       PROCESS_CALC_SIZES);
    14171477
     1478            if (pDlgData->lcidLast)
     1479            {
     1480                GpiSetCharSet(pDlgData->hps, LCID_DEFAULT);
     1481                GpiDeleteSetId(pDlgData->hps, pDlgData->lcidLast);
     1482            }
    14181483            if (pDlgData->hps)
    14191484                WinReleasePS(pDlgData->hps);
     
    15061571            PTABLEDEF pTable = (PTABLEDEF)pTableNode->pItemData;
    15071572
    1508             // for each table, clean up the rows
    1509             PLISTNODE pRowNode;
    1510             FOR_ALL_NODES(&pTable->llRows, pRowNode)
    1511             {
    1512                 PROWDEF pRow = (PROWDEF)pRowNode->pItemData;
    1513 
    1514                 // for each row, clean up the columns
    1515                 PLISTNODE pColumnNode;
    1516                 FOR_ALL_NODES(&pRow->llColumns, pColumnNode)
    1517                 {
    1518                     PCOLUMNDEF pColumn = (PCOLUMNDEF)pColumnNode->pItemData;
    1519                     free(pColumn);
    1520                 }
    1521                 lstClear(&pRow->llColumns);
    1522 
    1523                 free(pRow);
    1524             }
    1525             lstClear(&pTable->llRows);
    1526 
    1527             free(pTable);
     1573            FreeTable(pTable);
     1574                    // this may recurse for nested tables
    15281575        }
    15291576
     
    15321579
    15331580        free(pDlgData);
     1581    }
     1582
     1583    if (arc)
     1584    {
     1585        CHAR szErr[300];
     1586        sprintf(szErr, "Error %d occured in dlghCreateDlg.", arc);
     1587        winhDebugBox(hwndOwner,
     1588                     "Error in Dialog Manager",
     1589                     szErr);
    15341590    }
    15351591
  • trunk/src/helpers/dosh.c

    r86 r91  
    375375 */
    376376
    377 APIRET doshIsFixedDisk(ULONG  ulLogicalDrive,   // in: 1 for A:, 2 for B:, 3 for C:, ...
    378                        PBOOL  pfFixed)          // out: TRUE for fixed disks
     377APIRET doshIsFixedDisk(ULONG ulLogicalDrive,   // in: 1 for A:, 2 for B:, 3 for C:, ...
     378                       PBOOL pfFixed)          // out: TRUE for fixed disks
    379379{
    380380    APIRET arc = ERROR_INVALID_DRIVE;
     
    505505             && (pdp->usSectorsPerTrack == (USHORT)-1)
    506506           );
     507}
     508
     509/*
     510 *@@ doshHasAudioCD:
     511 *      sets *pfAudio to whether ulLogicalDrive
     512 *      currently has an audio CD inserted.
     513 *
     514 *      Better call this only if you're sure that
     515 *      ulLogicalDrive is a CD-ROM drive. Use
     516 *      doshIsCDROM to check.
     517 *
     518 *@@added V0.9.14 (2001-08-01) [umoeller]
     519 */
     520
     521APIRET doshHasAudioCD(ULONG ulLogicalDrive,
     522                      BOOL fMixedModeCD,
     523                      PBOOL pfAudio)
     524{
     525    APIRET  arc = NO_ERROR;
     526
     527    HFILE   hfDrive = 0;
     528    ULONG   ulTemp = 0;
     529
     530    CHAR    szDrive[3] = "C:";
     531    szDrive[0] = 'A' + ulLogicalDrive - 1;
     532
     533    *pfAudio = FALSE;
     534
     535    arc = DosOpen(szDrive,   // "C:", "D:", ...
     536                  &hfDrive,
     537                  &ulTemp,
     538                  0,
     539                  FILE_NORMAL,
     540                  OPEN_ACTION_FAIL_IF_NEW
     541                         | OPEN_ACTION_OPEN_IF_EXISTS,
     542                  OPEN_FLAGS_DASD
     543                         | OPEN_FLAGS_FAIL_ON_ERROR
     544                         | OPEN_FLAGS_NOINHERIT     // V0.9.6 (2000-11-25) [pr]
     545              //            | OPEN_ACCESS_READONLY  // V0.9.13 (2001-06-14) [umoeller]
     546                         | OPEN_SHARE_DENYNONE,
     547                  NULL);
     548
     549    // _Pmpf(("   DosOpen(OPEN_FLAGS_DASD) returned %d", arc));
     550
     551    // this still returns NO_ERROR for audio CDs in a
     552    // CD-ROM drive...
     553    // however, the WPS then attempts to read in the
     554    // root directory for audio CDs, which produces
     555    // a "sector not found" error box...
     556
     557    if (!arc && hfDrive)     // determined above
     558    {
     559        ULONG ulAudioTracks = 0,
     560              ulDataTracks = 0;
     561
     562        CHAR cds1[4] = { 'C', 'D', '0', '1' };
     563        CHAR cds2[4];
     564        // check for proper driver signature
     565        if (!(arc = doshDevIOCtl(hfDrive,
     566                                 IOCTL_CDROMDISK,
     567                                 CDROMDISK_GETDRIVER,
     568                                 &cds1, sizeof(cds1),
     569                                 &cds2, sizeof(cds2))))
     570        {
     571            if (memcmp(&cds1, &cds2, 4))
     572                // this is not a CD-ROM then:
     573                arc = NO_ERROR;
     574            else
     575            {
     576                struct {
     577                    UCHAR   ucFirstTrack,
     578                            ucLastTrack;
     579                    ULONG   ulLeadOut;
     580                } cdat;
     581
     582                // get track count
     583                if (!(arc = doshDevIOCtl(hfDrive,
     584                                         IOCTL_CDROMAUDIO,
     585                                         CDROMAUDIO_GETAUDIODISK,
     586                                         &cds1, sizeof(cds1),
     587                                         &cdat, sizeof(cdat))))
     588                {
     589                    // still no error: build the audio TOC
     590                    ULONG i;
     591                    for (i = cdat.ucFirstTrack;
     592                         i <= cdat.ucLastTrack;
     593                         i++)
     594                    {
     595                        BYTE cdtp[5] =
     596                          { 'C', 'D', '0', '1', (UCHAR)i };
     597
     598                        struct {
     599                            ULONG   ulTrackAddress;
     600                            BYTE    bFlags;
     601                        } trackdata;
     602
     603                        if (!(arc = doshDevIOCtl(hfDrive,
     604                                                 IOCTL_CDROMAUDIO,
     605                                                 CDROMAUDIO_GETAUDIOTRACK,
     606                                                 &cdtp, sizeof(cdtp),
     607                                                 &trackdata, sizeof(trackdata))))
     608                        {
     609                            if (trackdata.bFlags & 64)
     610                                ulDataTracks++;
     611                            else
     612                            {
     613                                ulAudioTracks++;
     614
     615                                if (!fMixedModeCD)
     616                                {
     617                                    // caller doesn't want mixed mode:
     618                                    // stop here
     619                                    ulDataTracks = 0;
     620                                    break;
     621                                }
     622                            }
     623                        }
     624                    }
     625
     626                    // _Pmpf(("   got %d audio, %d data tracks",
     627                    //             ulAudioTracks, ulDataTracks));
     628
     629                    if (!ulDataTracks)
     630                        *pfAudio = TRUE;
     631                }
     632                else
     633                {
     634                    // not audio disk:
     635                    // go on then
     636                    // _Pmpf(("   CDROMAUDIO_GETAUDIODISK returned %d", arc));
     637                    arc = NO_ERROR;
     638                }
     639            }
     640        }
     641        else
     642        {
     643            // not CD-ROM: go on then
     644            // _Pmpf(("   CDROMDISK_GETDRIVER returned %d", arc));
     645            arc = NO_ERROR;
     646        }
     647    }
     648
     649    if (hfDrive)
     650        DosClose(hfDrive);
     651
     652    return (arc);
    507653}
    508654
     
    679825                       ULONG fl)                // in: ASSERTFL_* flags
    680826{
    681     HFILE   hfDrive = 0;
    682     ULONG   ulTemp = 0;
    683827    APIRET  arc = NO_ERROR;
    684828    BOOL    fFixed = FALSE,
     
    713857        }
    714858
    715     if (!arc)
    716     {
    717         CHAR    szDrive[3] = "C:";
    718         szDrive[0] = 'A' + ulLogicalDrive - 1;
    719         arc = DosOpen(szDrive,   // "C:", "D:", ...
    720                       &hfDrive,
    721                       &ulTemp,
    722                       0,
    723                       FILE_NORMAL,
    724                       OPEN_ACTION_FAIL_IF_NEW
    725                              | OPEN_ACTION_OPEN_IF_EXISTS,
    726                       OPEN_FLAGS_DASD
    727                              | OPEN_FLAGS_FAIL_ON_ERROR
    728                              | OPEN_FLAGS_NOINHERIT     // V0.9.6 (2000-11-25) [pr]
    729                   //            | OPEN_ACCESS_READONLY  // V0.9.13 (2001-06-14) [umoeller]
    730                              | OPEN_SHARE_DENYNONE,
    731                       NULL);
    732 
    733         // _Pmpf(("   DosOpen(OPEN_FLAGS_DASD) returned %d", arc));
    734 
    735         // this still returns NO_ERROR for audio CDs in a
    736         // CD-ROM drive...
    737         // however, the WPS then attempts to read in the
    738         // root directory for audio CDs, which produces
    739         // a "sector not found" error box...
    740 
    741         if (!arc && hfDrive && fCDROM)     // determined above
    742         {
    743             ULONG ulAudioTracks = 0,
    744                   ulDataTracks = 0;
    745 
    746             CHAR cds1[4] = { 'C', 'D', '0', '1' };
    747             CHAR cds2[4];
    748             // check for proper driver signature
    749             if (!(arc = doshDevIOCtl(hfDrive,
    750                                      IOCTL_CDROMDISK,
    751                                      CDROMDISK_GETDRIVER,
    752                                      &cds1, sizeof(cds1),
    753                                      &cds2, sizeof(cds2))))
    754             {
    755                 if (memcmp(&cds1, &cds2, 4))
    756                     // this is not a CD-ROM then:
    757                     arc = NO_ERROR;
    758                 else
    759                 {
    760                     struct {
    761                         UCHAR   ucFirstTrack,
    762                                 ucLastTrack;
    763                         ULONG   ulLeadOut;
    764                     } cdat;
    765 
    766                     // get track count
    767                     if (!(arc = doshDevIOCtl(hfDrive,
    768                                              IOCTL_CDROMAUDIO,
    769                                              CDROMAUDIO_GETAUDIODISK,
    770                                              &cds1, sizeof(cds1),
    771                                              &cdat, sizeof(cdat))))
    772                     {
    773                         // still no error: build the audio TOC
    774                         ULONG i;
    775                         for (i = cdat.ucFirstTrack;
    776                              i <= cdat.ucLastTrack;
    777                              i++)
    778                         {
    779                             BYTE cdtp[5] =
    780                               { 'C', 'D', '0', '1', (UCHAR)i };
    781 
    782                             struct {
    783                                 ULONG   ulTrackAddress;
    784                                 BYTE    bFlags;
    785                             } trackdata;
    786 
    787                             if (!(arc = doshDevIOCtl(hfDrive,
    788                                                      IOCTL_CDROMAUDIO,
    789                                                      CDROMAUDIO_GETAUDIOTRACK,
    790                                                      &cdtp, sizeof(cdtp),
    791                                                      &trackdata, sizeof(trackdata))))
    792                             {
    793                                 if (trackdata.bFlags & 64)
    794                                     ulDataTracks++;
    795                                 else
    796                                 {
    797                                     ulAudioTracks++;
    798 
    799                                     if (!(fl & ASSERTFL_MIXEDMODECD))
    800                                     {
    801                                         // caller doesn't want mixed mode:
    802                                         // stop here
    803                                         ulDataTracks = 0;
    804                                         break;
    805                                     }
    806                                 }
    807                             }
    808                         }
    809 
    810                         // _Pmpf(("   got %d audio, %d data tracks",
    811                         //             ulAudioTracks, ulDataTracks));
    812 
    813                         if (!ulDataTracks)
    814                             arc = ERROR_AUDIO_CD_ROM;       // special private error code (10000)
    815                     }
    816                     else
    817                     {
    818                         // not audio disk:
    819                         // go on then
    820                         // _Pmpf(("   CDROMAUDIO_GETAUDIODISK returned %d", arc));
    821                         arc = NO_ERROR;
    822                     }
    823                 }
    824             }
    825             else
    826             {
    827                 // not CD-ROM: go on then
    828                 // _Pmpf(("   CDROMDISK_GETDRIVER returned %d", arc));
    829                 arc = NO_ERROR;
    830             }
    831         }
     859    if ((!arc) && (fCDROM))
     860    {
     861        BOOL fAudio;
     862        if (    (!(arc = doshHasAudioCD(ulLogicalDrive,
     863                                        ((fl & ASSERTFL_MIXEDMODECD) != 0),
     864                                        &fAudio)))
     865             && (fAudio)
     866           )
     867            arc = ERROR_AUDIO_CD_ROM;       // special private error code (10000)
    832868    }
    833869
     
    867903    }
    868904
    869     if (hfDrive)
    870         DosClose(hfDrive);
    871 
    872905    return (arc);
    873906}
     
    887920    CHAR    name[3] = "?:";
    888921    ULONG   fd = 0,
    889             action = 0,
    890             paramsize = 0,
    891             datasize = 0;
     922            action = 0;
     923//             paramsize = 0;
     924//             datasize = 0;
    892925    APIRET  rc = NO_ERROR;
    893926    USHORT  data,
     
    913946        param = 0;
    914947        data = (USHORT)ulLogicalDrive;
    915         paramsize = sizeof(param);
    916         datasize = sizeof(data);
     948        // paramsize = sizeof(param);
     949        // datasize = sizeof(data);
    917950        rc = doshDevIOCtl(fd,
    918951                          IOCTL_DISK, DSK_SETLOGICALMAP,
     
    941974    APIRET      arc = NO_ERROR;
    942975    FSALLOCATE  fsa;
    943     double      dbl = -1;
     976    // double      dbl = -1;
    944977
    945978    if (!(arc = DosQueryFSInfo(ulLogicalDrive, FSIL_ALLOC, &fsa, sizeof(fsa))))
     
    9671000    APIRET      arc = NO_ERROR;
    9681001    FSALLOCATE  fsa;
    969     double      dbl = -1;
     1002    // double      dbl = -1;
    9701003
    9711004    if (!(arc = DosQueryFSInfo(ulLogicalDrive, FSIL_ALLOC, &fsa, sizeof(fsa))))
     
    9831016 *
    9841017 *@@changed V0.9.1 (99-12-12) [umoeller]: added cbBuf to prototype
     1018 *@@changed V0.9.14 (2001-08-01) [umoeller]: fixed, this never respected cbBuf
    9851019 */
    9861020
     
    10151049            // Each data field following fsqBuffer.szName begins
    10161050            // immediately after the previous item.
    1017             strcpy(pszBuf,
    1018                    (CHAR*)(&pfsqBuffer->szName) + pfsqBuffer->cbName + 1);
     1051            strncpy(pszBuf,
     1052                    (CHAR*)(&pfsqBuffer->szName) + pfsqBuffer->cbName + 1,
     1053                    cbBuf);         // V0.9.14 (2001-08-01) [umoeller]
     1054            *(pszBuf + cbBuf) = '\0';
    10191055        }
    10201056    }
     
    24622498 ********************************************************************/
    24632499
    2464 static PVOID    G_pvGlobalInfoSeg = NULL,
     2500static PVOID    // G_pvGlobalInfoSeg = NULL,
    24652501                G_pvLocalInfoSeg = NULL;
    24662502
     
    24822518                    &LocalInfoSegSelector);
    24832519    // thunk
    2484     G_pvGlobalInfoSeg = (PVOID)(   (GlobalInfoSegSelector << 0x000D)
    2485                                  & 0x01fff0000);
     2520    /* G_pvGlobalInfoSeg = (PVOID)(   (GlobalInfoSegSelector << 0x000D)
     2521                                 & 0x01fff0000); */
    24862522    G_pvLocalInfoSeg  = (PVOID)(   (LocalInfoSegSelector << 0x000D)
    24872523                                 & 0x01fff0000);
  • trunk/src/helpers/dosh2.c

    r76 r91  
    753753VOID ParseBldLevel(PEXECUTABLE pExec)
    754754{
    755     const char  *pStartOfAuthor = 0,
     755    const char  // *pStartOfAuthor = 0,
    756756                *pStartOfVendor = 0;
    757757
     
    16011601        BYTE   bLen;
    16021602        CHAR   achName[256];
    1603         int    i;
     1603        // int    i;
    16041604
    16051605        ENSURE(DosRead(pExec->hfExe, &bLen, 1, &ulDummy));
     
    17471747            if (cFunctions)
    17481748            {
    1749                 USHORT usOrdinal = 1,
    1750                        usCurrent = 0;
     1749                // USHORT usOrdinal = 1;
     1750                       // usCurrent = 0;
    17511751
    17521752                paFunctions = (PFSYSFUNCTION)malloc(sizeof(FSYSFUNCTION) * cFunctions);
     
    37073707                ADDRESS hDrive = pDriveControlRecord->Drive_Handle;
    37083708
    3709                 Drive_Information_Record pDriveInfoRecord
     3709                /* Drive_Information_Record pDriveInfoRecord
    37103710                    = pLVMInfo->Get_Drive_Status(hDrive,
    37113711                                                 &Error);
     
    37133713                _Pmpf(("  drive %d Get_Drive_Status Error: %d", ulDisk, Error));
    37143714
    3715                 if (!Error)
     3715                if (!Error) */
    37163716                {
    37173717                    Partition_Information_Array PIA
     
    37703770                    }
    37713771                }
    3772                 else
     3772                /* else
    37733773                    // error:
    3774                     break;
     3774                    break; */
    37753775            }
    37763776
  • trunk/src/helpers/gpih.c

    r81 r91  
    603603 *
    604604 *      gpihFindFont uses this mutex. If you call GpiCreateLogFont
    605  *      yourself somewhere, do this after you called this function.
     605 *      yourself somewhere, you should do this under the protection
     606 *      of this function.
    606607 *
    607608 *      Call gpihUnlockLCIDs to unlock.
     
    612613BOOL gpihLockLCIDs(VOID)
    613614{
    614     BOOL brc = FALSE;
    615 
    616     if (G_hmtxLCIDs == NULLHANDLE)
     615    if (!G_hmtxLCIDs)
    617616        // first call: create
    618         brc = !DosCreateMutexSem(NULL,
    619                                  &G_hmtxLCIDs,
    620                                  0,
    621                                  TRUE);     // request!
    622     else
    623         // subsequent calls: request
    624         brc = !WinRequestMutexSem(G_hmtxLCIDs, SEM_INDEFINITE_WAIT);
    625 
    626     return (brc);
     617        return (!DosCreateMutexSem(NULL,
     618                                   &G_hmtxLCIDs,
     619                                   0,
     620                                   TRUE));     // request!
     621
     622    // subsequent calls: request
     623    return (!WinRequestMutexSem(G_hmtxLCIDs, SEM_INDEFINITE_WAIT));
    627624}
    628625
     
    741738        if (allcids)
    742739            free(allcids);
    743 
    744 /*
    745         PLONG   pBase;
    746         APIRET  arc;
    747 
    748         // _Pmpf(("gpihQueryNextFontID: calling DosAllocMem"));
    749 
    750         arc = DosAllocMem((PPVOID)(&pBase),
    751                           GQNCL_BLOCK_SIZE,
    752                                    // space is needed for an array of lCount longs.
    753                           PAG_READ |
    754                           PAG_WRITE);
    755         if (arc == NO_ERROR)
    756         {
    757             arc = DosSubSetMem(pBase,
    758                                DOSSUB_INIT | DOSSUB_SPARSE_OBJ,
    759                                GQNCL_BLOCK_SIZE);
    760             if (arc == NO_ERROR)
    761             {
    762                 PLONG  alTypes;  // object types
    763                 PSTR8  aNames;   // font names
    764                 PLONG  allcids;  // local identifiers
    765 
    766                 arc = DosSubAllocMem((PVOID)pBase,
    767                                      (PPVOID)(&aNames),
    768                                      (ULONG)(lCount*(ULONG)sizeof(STR8)));
    769                                              // space is needed for an array of
    770                                              // lCount longs
    771                 if (arc == NO_ERROR)
    772                 {
    773                     arc = DosSubAllocMem((PVOID)pBase,
    774                                              (PPVOID)(&allcids),
    775                                              (ULONG)lCount*sizeof(LONG));
    776                                                 // space is needed for an array of
    777                                                 // lCount longs.
    778                     if (arc == NO_ERROR)
    779                     {
    780                         arc = DosSubAllocMem((PVOID)pBase,
    781                                                  (PPVOID)(&alTypes),
    782                                                  (ULONG)lCount*sizeof(LONG));
    783                                                     // space is needed for an array of
    784                                                     // lCount longs.
    785                         if (arc == NO_ERROR)
    786                         {
    787                             if (GpiQuerySetIds(hps,
    788                                                lCount,
    789                                                alTypes,
    790                                                aNames,
    791                                                allcids))
    792                             {
    793                                 // FINALLY we have all the lcids in use.
    794                                 BOOL    fContinue = TRUE;
    795                                 lcidNext = 1;
    796 
    797                                 // now, check if this lcid is in use already:
    798                                 while (fContinue)
    799                                 {
    800                                     BOOL fFound = FALSE;
    801                                     ULONG ul;
    802                                     fContinue = FALSE;
    803                                     for (ul = 0;
    804                                          ul < lCount;
    805                                          ul++)
    806                                     {
    807                                         if (allcids[ul] == lcidNext)
    808                                         {
    809                                             fFound = TRUE;
    810                                             break;
    811                                         }
    812                                     }
    813 
    814                                     if (fFound)
    815                                     {
    816                                         // lcid found:
    817                                         // try next higher one
    818                                         lcidNext++;
    819                                         fContinue = TRUE;
    820                                     }
    821                                     // else: return that one
    822                                 }
    823                             }
    824                         }
    825                     }
    826                 }
    827             }
    828 
    829             arc = DosFreeMem(pBase);
    830         }
    831         */
    832740    }
    833741
     
    1006914 *@@changed V0.9.4 (2000-08-08) [umoeller]: added fFamily
    1007915 *@@changed V0.9.9 (2001-04-01) [umoeller]: made this thread-safe, finally
     916 *@@changed V0.9.14 (2001-08-01) [umoeller]: some optimizations
    1008917 */
    1009918
     
    1012921                  BOOL fFamily,          // in: if TRUE, pszName specifies font family;
    1013922                                         //     if FALSE, pszName specifies font face
    1014                   PSZ pszName,           // in: font family or face name (without point size)
     923                  const char *pcszName,  // in: font family or face name (without point size)
    1015924                  USHORT usFormat,       // in: none, one or several of:
    1016925                                         // -- FATTR_SEL_ITALIC
     
    1034943                                   sizeof(FONTMETRICS),
    1035944                                   NULL);
    1036     PFONTMETRICS pfm = (PFONTMETRICS)malloc(cFonts * sizeof(FONTMETRICS)),
    1037                  pfm2 = pfm,
    1038                  pfmFound = NULL;
     945    PFONTMETRICS    pfm = (PFONTMETRICS)malloc(cFonts * sizeof(FONTMETRICS)),
     946                    pfm2 = pfm,
     947                    pfmFound = NULL;
     948
     949    BOOL            fQueriedDevice = FALSE;     // V0.9.14 (2001-08-01) [umoeller]
     950    LONG            alDevRes[2];            // device resolution
    1039951
    1040952    // _Pmpf(("gpihFindFont: enumerating for %s, %d points", pszFaceName, lSize));
     
    1047959                                            // -- _not_ total buffer size!
    1048960                  pfm);
     961
    1049962    // now we have an array of FONTMETRICS
    1050963    // for EVERY font that is installed on the system...
     
    1066979    FontAttrs.fsSelection = usFormat; // changed later if better font is found
    1067980    FontAttrs.lMatch = 0L;             // closest match
    1068     strcpy(FontAttrs.szFacename, pszName);
     981    strcpy(FontAttrs.szFacename, pcszName);
    1069982    FontAttrs.idRegistry = 0;          // default registry
    1070983    FontAttrs.usCodePage = 0;          // default codepage
     
    10951008               pfm2->lAveCharWidth)); */
    10961009
    1097         PSZ pszCompare = (fFamily)
    1098                               ? pfm2->szFamilyname
    1099                               : pfm2->szFacename;
    1100 
    1101         if (strcmp(pszCompare, pszName) == 0)
     1010        const char *pcszCompare = (fFamily)
     1011                                     ? pfm2->szFamilyname
     1012                                     : pfm2->szFacename;
     1013
     1014        if (!strcmp(pcszCompare, pcszName))
    11021015        {
    11031016            /* _Pmpf(("  Found font %s; slope %d, usWeightClass %d",
     
    11171030                    // for bitmap fonts, there are always two versions:
    11181031                    // one for low resolutions, one for high resolutions
    1119                     LONG    alDevRes[2];
    1120                     DevQueryCaps(GpiQueryDevice(hps),
    1121                                  CAPS_HORIZONTAL_FONT_RES,
    1122                                  2L,
    1123                                  alDevRes);
     1032                    if (!fQueriedDevice)
     1033                    {
     1034                        DevQueryCaps(GpiQueryDevice(hps),
     1035                                     CAPS_HORIZONTAL_FONT_RES,
     1036                                     2L,
     1037                                     alDevRes);
     1038                        fQueriedDevice = TRUE;
     1039                    }
     1040
    11241041                    if (    (pfm2->sXDeviceRes == alDevRes[0])
    11251042                         && (pfm2->sYDeviceRes == alDevRes[1])
     
    11511068                                 && (pfm2->usWeightClass == 7) // bold
    11521069                                )
    1153                             ||  (   ((usFormat & FATTR_SEL_BOLD) == 0)
     1070                            ||  (   (!(usFormat & FATTR_SEL_BOLD))
    11541071                                 && (pfm2->usWeightClass == 5) // regular
    11551072                                )
     
    11581075                                 && (pfm2->sCharSlope != 0) // italics
    11591076                                )
    1160                             ||  (   ((usFormat & FATTR_SEL_ITALIC) == 0)
     1077                            ||  (   (!(usFormat & FATTR_SEL_ITALIC))
    11611078                                 && (pfm2->sCharSlope == 0) // regular
    11621079                                )
     
    20751992 *      You can then use any GPI function on the memory
    20761993 *      PS to draw into the bitmap. Use the fields from
    2077  *      _XBITMAP for that.
     1994 *      XBITMAP for that.
    20781995 *
    20791996 *      The bitmap is created in RGB mode.
     
    21442061 *
    21452062 *      To be on the safe side, this sets the
    2146  *      bitmap pointer to NULL as well.
     2063 *      given XBITMAP pointer to NULL as well.
    21472064 *
    21482065 *@@added V0.9.12 (2001-05-20) [umoeller]
  • trunk/src/helpers/helpers_pre.in

    r86 r91  
    5252
    5353CPOBJS = $(PLAINCOBJS) $(XMLOBJS) \
     54$(OUTPUTDIR)\apmh.obj \
    5455$(OUTPUTDIR)\datetime.obj \
    5556$(OUTPUTDIR)\debug.obj \
  • trunk/src/helpers/linklist.c

    r86 r91  
    8585#include "setup.h"                      // code generation and debugging options
    8686
     87#define DONT_REPLACE_LIST_MALLOC
    8788#include "helpers\linklist.h"
    8889
     
    263264}
    264265
    265 #else       // __DEBUG_MALLOC_ENABLED__
     266#endif
     267
     268// #else       // __DEBUG_MALLOC_ENABLED__
    266269
    267270/*
     
    295298}
    296299
    297 #endif      // __DEBUG_MALLOC_ENABLED__
     300// #endif      // __DEBUG_MALLOC_ENABLED__
    298301
    299302/*
     
    616619}
    617620
    618 #else  // __DEBUG_MALLOC_ENABLED__
     621#endif
     622
     623// #else  // __DEBUG_MALLOC_ENABLED__
    619624
    620625/*
     
    670675}
    671676
    672 #endif // __DEBUG_MALLOC_ENABLED__
     677// #endif // __DEBUG_MALLOC_ENABLED__
    673678
    674679/*
     
    790795 */
    791796
    792 BOOL lstRemoveNode(PLINKLIST pList, PLISTNODE pRemoveNode)
     797BOOL lstRemoveNode(PLINKLIST pList,
     798                   PLISTNODE pRemoveNode)
    793799{
    794800    BOOL fFound = FALSE;
  • trunk/src/helpers/memdebug.c

    r71 r91  
    382382        {
    383383            if (pHeapItem->pAfterMagic == p)
     384            {
    384385                // the same address may be allocated and freed
    385386                // several times, so if this address has been
     
    429430                    break;
    430431                } // if (!pHeapItem->fFreed)
     432            }
    431433
    432434            pHeapItem = pHeapItem->pNext;
     
    702704{
    703705    int i = 0;
     706    i++;
    704707}
    705708#endif
  • trunk/src/helpers/memdebug_win.c

    r71 r91  
    104104
    105105    ULONG       ulLine;
     106
     107    ULONG       ulAddress;      // has pAfterMagic, invisible, only
     108                                // for sorting V0.9.14 (2001-08-01) [umoeller]
    106109
    107110    PSZ         pszAddress;     // points to szAddress
     
    235238                }
    236239
    237                 sprintf(pMemRecordThis->szAddress, "0x%lX", pMemRecordThis->pObject);
    238                 strcpy(pMemRecordThis->szSource,
     240                pMemRecordThis->ulAddress = (ULONG)pMemRecordThis->pObject;
     241
     242                sprintf(pMemRecordThis->szAddress,
     243                        "0x%lX",
     244                        pMemRecordThis->pObject);
     245                strhcpy(pMemRecordThis->szSource,
    239246                        (pMemRecordThis->filename)
    240247                            ? pMemRecordThis->filename
     
    332339                pMemRecordThis->ulTID = pHeapItem->ulTID;
    333340
    334                 strcpy(pMemRecordThis->szSource, pHeapItem->pcszSourceFile);
     341                strhcpy(pMemRecordThis->szSource, pHeapItem->pcszSourceFile);
    335342                pMemRecordThis->pszSource = pMemRecordThis->szSource;
    336343
    337344                pMemRecordThis->ulLine = pHeapItem->ulLine;
    338345
    339                 strcpy(pMemRecordThis->szFunction, pHeapItem->pcszFunction);
     346                strhcpy(pMemRecordThis->szFunction, pHeapItem->pcszFunction);
    340347                pMemRecordThis->pszFunction = pMemRecordThis->szFunction;
    341348
    342                 sprintf(pMemRecordThis->szAddress, "0x%lX", pHeapItem->pAfterMagic);
     349                pMemRecordThis->ulAddress = (ULONG)pHeapItem->pAfterMagic;
     350
     351                sprintf(pMemRecordThis->szAddress,
     352                        "0x%lX",
     353                        pHeapItem->pAfterMagic);
    343354                pMemRecordThis->pszAddress = pMemRecordThis->szAddress;
    344355
     
    361372
    362373                sprintf(pMemRecordThis->szAddress, "0x%lX", pMemRecordThis->pObject);
    363                 strcpy(pMemRecordThis->szSource,
     374                strhcpy(pMemRecordThis->szSource,
    364375                        (pMemRecordThis->filename)
    365376                            ? pMemRecordThis->filename
     
    391402SHORT EXPENTRY mnu_fnCompareIndex(PMEMRECORD pmrc1, PMEMRECORD  pmrc2, PVOID pStorage)
    392403{
    393     // HAB habDesktop = WinQueryAnchorBlock(HWND_DESKTOP);
    394404    pStorage = pStorage; // to keep the compiler happy
    395405    if ((pmrc1) && (pmrc2))
     
    434444 *@@ mnu_fnCompareSourceFile:
    435445 *
    436  *V0.9.6 (2000-11-12) [umoeller]
     446 *@@added V0.9.6 (2000-11-12) [umoeller]
    437447 */
    438448
    439449SHORT EXPENTRY mnu_fnCompareSize(PMEMRECORD pmrc1, PMEMRECORD  pmrc2, PVOID pStorage)
    440450{
    441     HAB habDesktop = WinQueryAnchorBlock(HWND_DESKTOP);
    442451    pStorage = pStorage; // to keep the compiler happy
    443452    if ((pmrc1) && (pmrc2))
     
    452461}
    453462
     463/*
     464 *@@ mnu_fnCompareAddress:
     465 *
     466 *@@added V0.9.14 (2001-08-01) [umoeller]
     467 */
     468
     469SHORT EXPENTRY mnu_fnCompareAddress(PMEMRECORD pmrc1, PMEMRECORD  pmrc2, PVOID pStorage)
     470{
     471    pStorage = pStorage; // to keep the compiler happy
     472    if ((pmrc1) && (pmrc2))
     473    {
     474        if (pmrc1->ulAddress > pmrc2->ulAddress)
     475            return (1);
     476        else if (pmrc1->ulAddress < pmrc2->ulAddress)
     477            return (-1);
     478    }
     479
     480    return (0);
     481}
     482
    454483#define ID_MEMCNR   1000
    455484
     
    469498 *
    470499 *@@added V0.9.1 (99-12-04) [umoeller]
     500 *@@changed V0.9.14 (2001-08-01) [umoeller]: added sort by address
    471501 */
    472502
     
    648678                                       "Sort by object size",
    649679                                       MIS_TEXT, 0);
     680                    winhInsertMenuItem(G_hwndMemDebugMenu,
     681                                       MIT_END,
     682                                       1004,
     683                                       "Sort by address",
     684                                       MIS_TEXT, 0);
    650685
    651686                    WinSetFocus(HWND_DESKTOP, hwndCnr);
     
    715750                               CM_SORTRECORD,
    716751                               (MPARAM)mnu_fnCompareSize,
     752                               0);
     753                break;
     754
     755                case 1004: // sort by address V0.9.14 (2001-08-01) [umoeller]
     756                    WinSendMsg(WinWindowFromID(hwndClient, ID_MEMCNR),
     757                               CM_SORTRECORD,
     758                               (MPARAM)mnu_fnCompareAddress,
    717759                               0);
    718760                break;
     
    788830{
    789831    int i = 0;
     832    i++;
    790833}
    791834#endif
  • trunk/src/helpers/stringh.c

    r81 r91  
    5252#include "setup.h"                      // code generation and debugging options
    5353
     54#define DONT_REPLACE_STRINGH_MALLOC
    5455#include "helpers\stringh.h"
    5556#include "helpers\xstring.h"            // extended string helpers
     
    6869
    6970/*
     71 *@@ strcpy:
     72 *      like strdup, but this one doesn't crash if string2 is NULL,
     73 *      but sets the first byte in string1 to \0 instead.
     74 *
     75 *@@added V0.9.14 (2001-08-01) [umoeller]
     76 */
     77
     78PSZ strhcpy(PSZ string1, const char *string2)
     79{
     80    if (string2)
     81        return (strcpy(string1, string2));
     82
     83    *string1 = '\0';
     84    return (string1);
     85}
     86
     87#ifdef __DEBUG_MALLOC_ENABLED__
     88
     89/*
    7090 *@@ strhdup:
    71  *      like strdup, but this one
    72  *      doesn't crash if pszSource is NULL,
     91 *      memory debug version of strhdup.
     92 *
     93 *@@added V0.9.0 [umoeller]
     94 */
     95
     96PSZ strhdupDebug(const char *pszSource,
     97                 const char *pcszSourceFile,
     98                 unsigned long ulLine,
     99                 const char *pcszFunction)
     100{
     101    if (pszSource)
     102    {
     103        PSZ p = (PSZ)memdMalloc(strlen(pszSource) + 1,
     104                                pcszSourceFile,
     105                                ulLine,
     106                                pcszFunction);
     107        strcpy(p,  pszSource);
     108        return (p);
     109    }
     110    else
     111        return (0);
     112}
     113
     114#endif // __DEBUG_MALLOC_ENABLED__
     115
     116/*
     117 *@@ strhdup:
     118 *      like strdup, but this one doesn't crash if pszSource is NULL,
    73119 *      but returns NULL also.
    74120 *
     
    248294}
    249295
     296#ifdef __DEBUG_MALLOC_ENABLED__
     297
     298/*
     299 *@@ strhSubstrDebug:
     300 *      memory debug version of strhSubstr.
     301 *
     302 *@@added V0.9.14 (2001-08-01) [umoeller]
     303 */
     304
     305PSZ strhSubstrDebug(const char *pBegin,      // in: first char
     306                    const char *pEnd,        // in: last char (not included)
     307                    const char *pcszSourceFile,
     308                    unsigned long ulLine,
     309                    const char *pcszFunction)
     310{
     311    PSZ pszSubstr = NULL;
     312
     313    if (pEnd > pBegin)      // V0.9.9 (2001-04-04) [umoeller]
     314    {
     315        ULONG cbSubstr = (pEnd - pBegin);
     316        if (pszSubstr = (PSZ)memdMalloc(cbSubstr + 1,
     317                                        pcszSourceFile,
     318                                        ulLine,
     319                                        pcszFunction))
     320        {
     321            // strhncpy0(pszSubstr, pBegin, cbSubstr);
     322            memcpy(pszSubstr, pBegin, cbSubstr);        // V0.9.9 (2001-04-04) [umoeller]
     323            *(pszSubstr + cbSubstr) = '\0';
     324        }
     325    }
     326
     327    return (pszSubstr);
     328}
     329
     330#endif // __DEBUG_MALLOC_ENABLED__
     331
    250332/*
    251333 *@@ strhSubstr:
     
    274356    {
    275357        ULONG cbSubstr = (pEnd - pBegin);
    276         pszSubstr = (PSZ)malloc(cbSubstr + 1);
    277         if (pszSubstr)
     358        if (pszSubstr = (PSZ)malloc(cbSubstr + 1))
    278359        {
    279             // strhncpy0(pszSubstr, pBegin, cbSubstr);
    280360            memcpy(pszSubstr, pBegin, cbSubstr);        // V0.9.9 (2001-04-04) [umoeller]
    281361            *(pszSubstr + cbSubstr) = '\0';
  • trunk/src/helpers/textv_html.c

    r82 r91  
    13411341            // end of tag found:
    13421342            ULONG cbTag;
    1343             PSZ pStartOfAttrs = 0;
     1343            // PSZ pStartOfAttrs = 0;
    13441344
    13451345            if ((pNextSpace) && (pNextSpace < pNextClose))
     
    13471347                // we have attributes:
    13481348                cbTag = pNextSpace - (pStartOfTag + 1);
    1349                 pStartOfAttrs = pNextSpace;
     1349                // pStartOfAttrs = pNextSpace;
    13501350            }
    13511351            else
  • trunk/src/helpers/textview.c

    r85 r91  
    625625                    pWordEnd = NULL;
    626626        PSZ         pCheck = *ppStartOfWord;
    627         ULONG       cChars = 0,
    628                     cCheck = 0;
     627        ULONG       cChars = 0;
     628                    // cCheck = 0;
    629629
    630630        pWord = (PTXVWORD)malloc(sizeof(TXVWORD));
     
    656656            // cChars is != 0 if strhGetWord succeeded AND the
    657657            // line is not empty, so go on
    658             cCheck = cChars;
     658            // cCheck = cChars;
    659659
    660660            // advance input pointer
     
    30483048                        if (ptxvd->cdata.flStyle & XTXF_VSCROLL)
    30493049                        {
    3050                             BOOL fEnabled = winhUpdateScrollBar(ptxvd->hwndVScroll,
     3050                            /* BOOL fEnabled = */ winhUpdateScrollBar(ptxvd->hwndVScroll,
    30513051                                                                ulWinCY,
    30523052                                                                ptxvd->xfd.ulViewportCY,
     
    32193219                      NULL);    // reserved
    32203220
    3221     if (cbNeeded)
     3221    if (!rc && cbNeeded)
    32223222    {
    32233223        pprq3 = (PRQINFO3*)malloc(cbNeeded);
  • trunk/src/helpers/timer.c

    r86 r91  
    110110#include "helpers\linklist.h"
    111111#include "helpers\math.h"
     112#include "helpers\standards.h"
    112113#include "helpers\threads.h"
    113114#include "helpers\timer.h"
     
    248249{
    249250    PLINKLIST pllXTimers = (PLINKLIST)pSet->pvllXTimers;
    250     PLISTNODE pNode = lstQueryFirstNode(pllXTimers);
    251     if (!pNode)
     251    ULONG   cTimers = lstCountItems(pllXTimers);
     252    if (!cTimers)
    252253    {
    253254        // no XTimers running:
     
    268269        // we have timers:
    269270
    270         ULONG ulOldPMTimeout = pSet->ulPMTimeout;
    271 
    272         if (!pNode->pNext)
     271        ULONG       ulOldPMTimeout = pSet->ulPMTimeout;
     272
     273        PLISTNODE   pNode = lstQueryFirstNode(pllXTimers);
     274        PXTIMER     pTimer1 = (PXTIMER)pNode->pItemData;
     275
     276        if (cTimers == 1)
    273277        {
    274278            // only one timer:
    275279            // that's easy
    276             PXTIMER pTimer = (PXTIMER)pNode->pItemData;
    277             pSet->ulPMTimeout = pTimer->ulTimeout;
    278         }
    279         else if (!pNode->pNext->pNext)
     280            pSet->ulPMTimeout = pTimer1->ulTimeout;
     281        }
     282        else if (cTimers == 2)
    280283        {
    281284            // exactly two timers:
    282285            // find the greatest common denominator
    283             PXTIMER pTimer1 = (PXTIMER)pNode->pItemData,
    284                     pTimer2 = (PXTIMER)pNode->pNext->pItemData;
     286            PXTIMER pTimer2 = (PXTIMER)pNode->pNext->pItemData;
    285287
    286288            pSet->ulPMTimeout = mathGCD(pTimer1->ulTimeout,
     
    289291        else
    290292        {
    291             // several timers:
     293            // more than two timers:
    292294            // run through all timers and find the greatest
    293295            // common denominator of all frequencies...
    294 
    295             ULONG   cTimers = lstCountItems(pllXTimers);
    296296            int     *paInts = (int*)_alloca(sizeof(int) * cTimers),
    297297                    i = 0;
    298298
    299             _Pmpf(("Recalculating, got %d timers %d", cTimers));
     299            // _Pmpf(("Recalculating, got %d timers", cTimers));
    300300
    301301            // fill an array of integers with the
     
    303303            while (pNode)
    304304            {
    305                 PXTIMER pTimer = (PXTIMER)pNode->pItemData;
    306 
    307                 _Pmpf(("  timeout %d is %d", i, pTimer->ulTimeout));
    308 
    309                 paInts[i++] = pTimer->ulTimeout;
     305                pTimer1 = (PXTIMER)pNode->pItemData;
     306
     307                // _Pmpf(("  timeout %d is %d", i, pTimer1->ulTimeout));
     308
     309                paInts[i++] = pTimer1->ulTimeout;
    310310
    311311                pNode = pNode->pNext;
     
    314314            pSet->ulPMTimeout = mathGCDMulti(paInts,
    315315                                             cTimers);
    316             _Pmpf(("--> GCD is %d", pSet->ulPMTimeout));
    317         }
    318 
    319         if (    (pSet->idPMTimerRunning == 0)       // timer not running?
     316            // _Pmpf(("--> GCD is %d", pSet->ulPMTimeout));
     317        }
     318
     319        if (    (!pSet->idPMTimerRunning)       // timer not running?
    320320             || (pSet->ulPMTimeout != ulOldPMTimeout) // timeout changed?
    321321           )
     
    355355                        USHORT usPMTimerID)
    356356{
    357     PXTIMERSET pSet = NULL;
    358 
    359     pSet = (PXTIMERSET)malloc(sizeof(*pSet));
     357    PXTIMERSET pSet = NEW(XTIMERSET);
    360358    if (pSet)
    361359    {
     
    434432 *@@added V0.9.9 (2001-02-28) [umoeller]
    435433 *@@changed V0.9.12 (2001-05-12) [umoeller]: added mutex protection
    436  *@@changed V0.9.12 (2001-05-24) [umoeller]: fixed crash if timer was deleted during winproc's WM_TIMER processing
     434 *@@changed V0.9.12 (2001-05-24) [umoeller]: fixed crash if this got called during tmrTimerTick
     435 *@@changed V0.9.14 (2001-08-01) [umoeller]: fixed mem overwrite which might have caused crashes if this got called during tmrTimerTick
    437436 */
    438437
     
    498497                                PFNWP pfnwp = (PFNWP)WinQueryWindowPtr(pTimer->hwndTarget,
    499498                                                                       QWP_PFNWP);
     499
     500                                // moved this up V0.9.14 (2001-08-01) [umoeller]
     501                                pTimer->ulNextFire = ulTimeNow + pTimer->ulTimeout;
     502
    500503                                // call the window proc DIRECTLY
    501504                                pfnwp(pTimer->hwndTarget,
     
    511514                                    //    the list, so we'll see it in this loop
    512515
    513                                 pTimer->ulNextFire = ulTimeNow + pTimer->ulTimeout;
     516                                // V0.9.14 (2001-08-01) [umoeller]
     517
     518                                // DO NOT REFERENCE pTimer AFTER THIS CODE;
     519                                // tmrTimerTick might have removed the timer,
     520                                // and since the list is auto-free, pTimer
     521                                // might have been freed!!
    514522                            }
    515523                            else
     
    598606
    599607                // fix the timeout... we allow only multiples of
    600                 // 20, and it must be at least 20 (otherwise our
     608                // 25, and it must be at least 25 (otherwise our
    601609                // internal master timer calculations will fail)
    602610                // V0.9.14 (2001-07-07) [umoeller]
     
    607615
    608616                // check if this timer exists already
    609                 pTimer = FindTimer(pSet,
    610                                    hwnd,
    611                                    usTimerID);
    612                 if (pTimer)
     617                if (pTimer = FindTimer(pSet,
     618                                       hwnd,
     619                                       usTimerID))
    613620                {
    614621                    // exists already: reset only
     
    617624                                    &ulTimeNow, sizeof(ulTimeNow));
    618625                    pTimer->ulNextFire = ulTimeNow + ulTimeout;
    619                     usrc = pTimer->usTimerID;
     626                    usrc = usTimerID;
    620627                }
    621628                else
    622629                {
    623630                    // new timer needed:
    624                     pTimer = (PXTIMER)malloc(sizeof(XTIMER));
    625                     if (pTimer)
     631                    if (pTimer = NEW(XTIMER))
    626632                    {
    627633                        ULONG ulTimeNow;
     
    635641                        lstAppendItem(pllXTimers,
    636642                                      pTimer);
    637                         usrc = pTimer->usTimerID;
     643                        usrc = usTimerID;
    638644                    }
    639645                }
     
    673679        if (pSet && pSet->pvllXTimers)
    674680        {
    675             PLINKLIST pllXTimers = (PLINKLIST)pSet->pvllXTimers;
    676             BOOL fLocked = FALSE;
     681            // PLINKLIST pllXTimers = (PLINKLIST)pSet->pvllXTimers;
    677682
    678683            PXTIMER pTimer = FindTimer(pSet,
  • trunk/src/helpers/winh.c

    r85 r91  
    601601                             i++)
    602602                        {
    603                             CHAR szItemText[100];
     603                            // CHAR szItemText[100];
    604604                            SHORT id = SHORT1FROMMR(WinSendMsg(mi.hwndSubMenu,
    605605                                                         MM_ITEMIDFROMPOSITION,
     
    689689        MENUITEM mi = {0};
    690690        SHORT src = 0;
    691         SHORT s = 0;
     691        // SHORT s = 0;
    692692        mi.iPosition = MIT_END;
    693693        mi.afStyle = MIS_TEXT | MIS_SUBMENU;
     
    744744 *      to free the return value.
    745745 *
     746 *      This uses MM_QUERYITEMTEXT internally.
     747 *      PMREF doesn't say anything about this,
     748 *      but from my testing this always recurses
     749 *      into submenus.
     750 *
    746751 *      Use the WinSetMenuItemText macro to
    747752 *      set the menu item text.
     
    753758    PSZ     prc = NULL;
    754759
    755     SHORT sLength = SHORT1FROMMR(WinSendMsg(hwndMenu, MM_QUERYITEMTEXTLENGTH,
    756                                            (MPARAM)(ULONG)usItemID,
    757                                            (MPARAM)NULL));
     760    SHORT sLength = SHORT1FROMMR(WinSendMsg(hwndMenu,
     761                                            MM_QUERYITEMTEXTLENGTH,
     762                                            (MPARAM)(ULONG)usItemID,
     763                                            (MPARAM)NULL));
    758764    if (sLength)
    759765    {
     
    40634069{
    40644070    SWBLOCK  swblock;
    4065     HWND     hwndTasklist = winhQueryTasklistWindow();
     4071    // HWND     hwndTasklist = winhQueryTasklistWindow();
    40664072    // the tasklist has entry #0 in the SWBLOCK
    40674073    WinQuerySwitchList(NULLHANDLE, &swblock, sizeof(SWBLOCK));
  • trunk/src/helpers/xml.c

    r83 r91  
    455455            case ATTRIBUTE_DECLARATION:
    456456            {
    457                 PCMATTRIBUTEDECL pDecl = (PCMATTRIBUTEDECL)pNode;
     457                // PCMATTRIBUTEDECL pDecl = (PCMATTRIBUTEDECL)pNode;
    458458            break; }
    459459
     
    15241524    if (!pDom->arcDOM)
    15251525    {
    1526         ULONG       i;
     1526        // ULONG       i;
    15271527
    15281528        if (len)
     
    15331533            if (!pDom->arcDOM)
    15341534            {
    1535                 PDOMNODE    pParent = pSI->pDomNode,
    1536                             pNew = NULL;
     1535                PDOMNODE    pParent = pSI->pDomNode;
     1536                            // pNew = NULL;
    15371537
    15381538                // shall we validate?
     
    25882588                                  const char *pcszName)
    25892589{
    2590     APIRET arc = NO_ERROR;
     2590    // APIRET arc = NO_ERROR;
    25912591
    25922592    PLINKLIST pll = lstCreate(FALSE);       // no free
  • trunk/src/helpers/xprf.c

    r65 r91  
    434434                                                pKey->lenKeyData);
    435435
    436                                 if (!pKey)
     436                                if (!pIniKey)
    437437                                {
    438438                                    brc = FALSE;
  • trunk/src/helpers/xstring.c

    r86 r91  
    112112
    113113#include "helpers\stringh.h"
     114#define DONT_REPLACE_XSTR_MALLOC
    114115#include "helpers\xstring.h"            // extended string helpers
    115116
     
    118119 *      See xstring.c.
    119120 */
     121
     122#ifdef __DEBUG_MALLOC_ENABLED__
     123
     124/*
     125 *@@ xstrInitDebug:
     126 *
     127 *@@added V0.9.14 (2001-08-01) [umoeller]
     128 */
     129
     130void XWPENTRY xstrInitDebug(PXSTRING pxstr,
     131                            ULONG ulPreAllocate,
     132                            const char *file,
     133                            unsigned long line,
     134                            const char *function)
     135{
     136    memset(pxstr, 0, sizeof(XSTRING));
     137    if (ulPreAllocate)
     138    {
     139        pxstr->psz = (PSZ)memdMalloc(ulPreAllocate,
     140                                     file,
     141                                     line,
     142                                     function);
     143        pxstr->cbAllocated = ulPreAllocate;
     144                // ulLength is still zero
     145        *(pxstr->psz) = 0;
     146
     147        pxstr->ulDelta = ulPreAllocate * 10 / 100;
     148    }
     149
     150    // else: pxstr->ulDelta is still 0
     151    pxstr->file = file;
     152    pxstr->line = line;
     153    pxstr->function = function;
     154}
     155
     156#endif // __DEBUG_MALLOC_ENABLED__
    120157
    121158/*
     
    319356        // this gives the C runtime a chance to expand the
    320357        // existing block
    321         if (pxstr->psz = (PSZ)realloc(pxstr->psz, cbAllocate))
     358#ifdef __DEBUG_MALLOC_ENABLED__
     359        if (pxstr->psz = (PSZ)memdRealloc(pxstr->psz,
     360                                          cbAllocate,
     361                                          pxstr->file,
     362                                          pxstr->line,
     363                                          pxstr->function))
     364#else
     365        if (pxstr->psz = (PSZ)realloc(pxstr->psz,
     366                                      cbAllocate))
     367#endif
    322368                    // if pxstr->psz is NULL, realloc behaves like malloc
    323369            pxstr->cbAllocated = cbAllocate;
Note: See TracChangeset for help on using the changeset viewer.