Changeset 132


Ignore:
Timestamp:
Jan 19, 2002, 11:50:39 AM (24 years ago)
Author:
umoeller
Message:

Misc changes.

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/helpers/dialog.h

    r117 r132  
    6363    #define SZL_AUTOSIZE                (-1)
    6464
    65     #define CTL_COMMON_FONT             ((const char *)-1)
     65    #define CTL_COMMON_FONT             ((PCSZ)-1)
    6666
    6767    #define ROW_VALIGN_MASK             0x0003
     
    117117
    118118    } CONTROLDEF, *PCONTROLDEF;
     119
     120    typedef const struct _CONTROLDEF *PCCONTROLDEF;
    119121
    120122    /*
     
    178180    } DLGHITEM, *PDLGHITEM;
    179181
     182    typedef const struct _DLGHITEM *PCDLGHITEM;
     183
    180184    /* ******************************************************************
    181185     *
     
    256260                                  ULONG flCreateFlags,
    257261                                  PFNWP pfnwpDialogProc,
    258                                   const char *pcszDlgTitle,
    259                                   PDLGHITEM paDlgItems,
     262                                  PCSZ pcszDlgTitle,
     263                                  PCDLGHITEM paDlgItems,
    260264                                  ULONG cDlgItems,
    261265                                  PVOID pCreateParams,
    262                                   const char *pcszControlsFont);
     266                                  PCSZ pcszControlsFont);
    263267    typedef APIRET XWPENTRY DLGHCREATEDLG(HWND *phwndDlg,
    264268                                          HWND hwndOwner,
    265269                                          ULONG flCreateFlags,
    266270                                          PFNWP pfnwpDialogProc,
    267                                           const char *pcszDlgTitle,
    268                                           PDLGHITEM paDlgItems,
     271                                          PCSZ pcszDlgTitle,
     272                                          PCDLGHITEM paDlgItems,
    269273                                          ULONG cDlgItems,
    270274                                          PVOID pCreateParams,
    271                                           const char *pcszControlsFont);
     275                                          PCSZ pcszControlsFont);
    272276    typedef DLGHCREATEDLG *PDLGHCREATEDLG;
    273277
    274278    APIRET dlghFormatDlg(HWND hwndDlg,
    275                          PDLGHITEM paDlgItems,
     279                         PCDLGHITEM paDlgItems,
    276280                         ULONG cDlgItems,
    277                          const char *pcszControlsFont,
     281                         PCSZ pcszControlsFont,
    278282                         ULONG flFlags);
    279283
     
    311315
    312316    APIRET dlghAppendToArray(PDLGARRAY pArray,
    313                              DLGHITEM *paItems,
     317                             PCDLGHITEM paItems,
    314318                             ULONG cItems);
    315319
     
    368372                                HWND hwndOwner,
    369373                                HPOINTER hptrIcon,
    370                                 const char *pcszTitle,
    371                                 const char *pcszMessage,
     374                                PCSZ pcszTitle,
     375                                PCSZ pcszMessage,
    372376                                ULONG flFlags,
    373                                 const char *pcszFont,
     377                                PCSZ pcszFont,
    374378                                const MSGBOXSTRINGS *pStrings,
    375379                                PULONG pulAlarmFlag);
     
    377381    ULONG dlghMessageBox(HWND hwndOwner,
    378382                         HPOINTER hptrIcon,
    379                          const char *pcszTitle,
    380                          const char *pcszMessage,
     383                         PCSZ pcszTitle,
     384                         PCSZ pcszMessage,
    381385                         ULONG flFlags,
    382                          const char *pcszFont,
     386                         PCSZ pcszFont,
    383387                         const MSGBOXSTRINGS *pStrings);
    384388
     
    388392
    389393    PSZ dlghTextEntryBox(HWND hwndOwner,
    390                          const char *pcszTitle,
    391                          const char *pcszDescription,
    392                          const char *pcszDefault,
    393                          const char *pcszOK,
    394                          const char *pcszCancel,
     394                         PCSZ pcszTitle,
     395                         PCSZ pcszDescription,
     396                         PCSZ pcszDefault,
     397                         PCSZ pcszOK,
     398                         PCSZ pcszCancel,
    395399                         ULONG ulMaxLen,
    396400                         ULONG fl,
    397                          const char *pcszFont);
     401                         PCSZ pcszFont);
    398402
    399403    /* ******************************************************************
  • trunk/include/helpers/dosh.h

    r131 r132  
    219219     ********************************************************************/
    220220
     221    APIRET doshQueryProcAddr(PCSZ pcszModuleName,
     222                             ULONG ulOrdinal,
     223                             PFN *ppfn);
     224
    221225    /*
    222226     *@@ RESOLVEFUNCTION:
     
    233237    } RESOLVEFUNCTION, *PRESOLVEFUNCTION;
    234238
    235     APIRET doshResolveImports(PSZ pszModuleName,
     239    typedef const struct _RESOLVEFUNCTION *PCRESOLVEFUNCTION;
     240
     241    APIRET doshResolveImports(PCSZ pcszModuleName,
    236242                              HMODULE *phmod,
    237                               PRESOLVEFUNCTION paResolves,
     243                              PCRESOLVEFUNCTION paResolves,
    238244                              ULONG cResolves);
    239245
     
    694700     ********************************************************************/
    695701
    696     BOOL doshMatch(const char *pcszMask,
    697                    const char *pcszName);
     702    BOOL doshMatch(PCSZ pcszMask,
     703                   PCSZ pcszName);
    698704
    699705#endif
  • trunk/include/helpers/standards.h

    r129 r132  
    8181     */
    8282
    83     #define FREE(ptr) if ((ptr)) { free(ptr); ptr = NULL; }
     83    #define FREE(ptr)  { if ((ptr)) { free(ptr); ptr = NULL; } }
    8484
    8585    /*
     
    104104     */
    105105
    106     #define ARRAYITEMCOUNT(array) sizeof(array) / sizeof(array[0])
     106    #define ARRAYITEMCOUNT(array) (sizeof(array) / sizeof(array[0]))
    107107
    108108    /*
  • trunk/include/helpers/xstring.h

    r129 r132  
    8686    typedef void XWPENTRY XSTRINIT(PXSTRING pxstr, ULONG ulPreAllocate);
    8787    typedef XSTRINIT *PXSTRINIT; */
     88
     89    void xstrInitSet2(PXSTRING pxstr, PSZ pszNew, ULONG ulNewLength);
    8890
    8991    void XWPENTRY xstrInitSet(PXSTRING pxstr, PSZ pszNew);
     
    132134    typedef XSTRFREE *PXSTRFREE;
    133135
     136    ULONG XWPENTRY xstrset2(PXSTRING pxstr, PSZ pszNew, ULONG ulNewLength);
     137
    134138    ULONG XWPENTRY xstrset(PXSTRING pxstr, PSZ pszNew);
    135139    typedef ULONG XWPENTRY XSTRSET(PXSTRING pxstr, PSZ pszNew);
  • trunk/src/helpers/comctl.c

    r123 r132  
    977977 */
    978978
    979 PANIMATIONDATA CreateAnimationData(HWND hwndStatic,
     979PANIMATIONDATA CreateAnimationData(HAB hab,
     980                                   HWND hwndStatic,
    980981                                   USHORT cAnimations)
    981982{
     
    996997            WinSetWindowULong(hwndStatic, QWL_USER, (ULONG)pa);
    997998
    998             pa->hab = WinQueryAnchorBlock(hwndStatic);
     999            pa->hab = hab;
    9991000            WinQueryWindowRect(hwndStatic, &pa->rclIcon);
    10001001            pa->OldStaticProc = WinSubclassWindow(hwndStatic, ctl_fnwpBitmapStatic);
     
    10461047{
    10471048    PANIMATIONDATA pa;
    1048 
    1049     if (pa = CreateAnimationData(hwndStatic,
    1050                                  usAnimCount))
     1049    HAB     hab;
     1050    if (    (hwndStatic)
     1051         && (hab = WinQueryAnchorBlock(hwndStatic))
     1052         && (WinIsWindow(hab, hwndStatic))
     1053         && (pa = CreateAnimationData(hab,
     1054                                      hwndStatic,
     1055                                      usAnimCount))
     1056       )
    10511057    {
    10521058        // switch static to icon mode
    10531059        pa->ulFlags = ANF_ICON;
     1060        return (pa);
    10541061    }
    10551062
    1056     return (pa);
     1063    return (NULL);
    10571064}
    10581065
     
    12331240{
    12341241    PANIMATIONDATA pa;
    1235 
    1236     if (pa = CreateAnimationData(hwndStatic, 1))
     1242    HAB hab;
     1243    if (    (hwndStatic)
     1244         && (hab = WinQueryAnchorBlock(hwndStatic))
     1245         && (WinIsWindow(hab, hwndStatic))
     1246         && (pa = CreateAnimationData(hab, hwndStatic, 1))
     1247       )
    12371248    {
    12381249        // switch static to bitmap mode
     
    12401251        if (fPreserveProportions)
    12411252            pa->ulFlags |= ANF_PROPORTIONAL;
     1253        return (pa);
    12421254    }
    12431255
    1244     return (pa);
     1256    return NULL;
    12451257}
    12461258
  • trunk/src/helpers/dialog.c

    r123 r132  
    234234{
    235235    LONG lPointSize = 0;
    236     const char *pcszFontThis = pControlDef->pcszFont;
     236    PCSZ pcszFontThis = pControlDef->pcszFont;
    237237                    // can be NULL,
    238238                    // or CTL_COMMON_FONT
     
    12401240
    12411241APIRET Dlg1_ParseTables(PDLGPRIVATE pDlgData,
    1242                         PDLGHITEM paDlgItems,      // in: definition array
     1242                        PCDLGHITEM paDlgItems,      // in: definition array
    12431243                        ULONG cDlgItems)           // in: array item count (NOT array size)
    12441244{
     
    12561256         ul++)
    12571257    {
    1258         PDLGHITEM   pItemThis = &paDlgItems[ul];
     1258        PCDLGHITEM   pItemThis = &paDlgItems[ul];
    12591259
    12601260        switch (pItemThis->Type)
     
    15841584 *          it produces a static group control around the table.
    15851585 *          Useful for group boxes. pDef must point to a
    1586  *          _CONTROLDEF describing the control to be used for
     1586 *          CONTROLDEF describing the control to be used for
    15871587 *          the group (usually a WC_STATIC with SS_GROUP style),
    15881588 *          whose size parameter is ignored.
     
    16021602 *          pDef must point to a CONTROLDEF structure.
    16031603 *
    1604  *          Again, there is is NO information in
    1605  *          CONTROLDEF about a control's _position_.
    1606  *          Instead, the structure only contains the _size_
    1607  *          of the control. All positions are computed by
    1608  *          this function, depending on the sizes of the
    1609  *          controls and their nesting within the various tables.
    1610  *
    1611  *          If you specify SZL_AUTOSIZE, the size of the
    1612  *          control is even computed automatically. Presently,
    1613  *          this only works for statics with SS_TEXT, SS_ICON,
    1614  *          and SS_BITMAP.
     1604 *          Again, there is is NO information in CONTROLDEF
     1605 *          about a control's _position_. Instead, the structure
     1606 *          only contains the _size_ of the control. All
     1607 *          positions are computed by this function, depending
     1608 *          on the sizes of the controls and their nesting within
     1609 *          the various tables.
     1610 *
     1611 *          If you specify SZL_AUTOSIZE with either cx or cy
     1612 *          or both, the size of the control is even computed
     1613 *          automatically. Presently, this only works for statics
     1614 *          with SS_TEXT, SS_ICON, and SS_BITMAP, push buttons,
     1615 *          and radio and check boxes.
    16151616 *
    16161617 *          Unless separated with START_ROW items, subsequent
     
    16211622 *      an error:
    16221623 *
    1623  *      -- The entire array must be enclosed in a table
    1624  *         (the "root" table).
    1625  *
    1626  *      -- After START_TABLE or START_GROUP_TABLE, there must
    1627  *         always be a START_ROW first.
     1624 *      --  The entire array must be enclosed in a table
     1625 *          (the "root" table).
     1626 *
     1627 *      --  After START_TABLE or START_GROUP_TABLE, there must
     1628 *          always be a START_ROW first.
    16281629 *
    16291630 *      To create a dialog, set up arrays like the following:
     
    16861687 +          º ³  ³                        ³  ³  º
    16871688 +          º ³  ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ  ³  º
     1689 +          º ³                              ³  º
    16881690 +          º ³  Static below cnr (3)        ³  º
    16891691 +          º ³                              ³  º
    16901692 +          º ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ  º
     1693 +          º                                   º
    16911694 +          º ÚÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿     º
    16921695 +          º ³   OK (4)  ³ ³  Cancel (5) ³     º
     
    17561759                     ULONG flCreateFlags,       // in: standard FCF_* frame flags
    17571760                     PFNWP pfnwpDialogProc,
    1758                      const char *pcszDlgTitle,
    1759                      PDLGHITEM paDlgItems,      // in: definition array
     1761                     PCSZ pcszDlgTitle,
     1762                     PCDLGHITEM paDlgItems,      // in: definition array
    17601763                     ULONG cDlgItems,           // in: array item count (NOT array size)
    17611764                     PVOID pCreateParams,       // in: for mp2 of WM_INITDLG
    1762                      const char *pcszControlsFont) // in: font for ctls with CTL_COMMON_FONT
     1765                     PCSZ pcszControlsFont) // in: font for ctls with CTL_COMMON_FONT
    17631766{
    17641767    APIRET      arc = NO_ERROR;
     
    18401843                 */
    18411844
    1842                 Dlg2_CalcSizes(pDlgData,
    1843                                &szlClient);
    1844 
    1845                 WinSubclassWindow(hwndDlg, pfnwpDialogProc);
    1846 
    1847                 /*
    1848                  *  4) compute size of dialog client from total
    1849                  *     size of all controls
    1850                  */
    1851 
    1852                 // calculate the frame size from the client size
    1853                 rclClient.xLeft = 10;
    1854                 rclClient.yBottom = 10;
    1855                 rclClient.xRight = szlClient.cx + 2 * SPACING;
    1856                 rclClient.yTop = szlClient.cy + 2 * SPACING;
    1857                 WinCalcFrameRect(hwndDlg,
    1858                                  &rclClient,
    1859                                  FALSE);            // frame from client
    1860 
    1861                 WinSetWindowPos(hwndDlg,
    1862                                 0,
    1863                                 10,
    1864                                 10,
    1865                                 rclClient.xRight,
    1866                                 rclClient.yTop,
    1867                                 SWP_MOVE | SWP_SIZE | SWP_NOADJUST);
    1868 
    1869                 arc = Dlg3_PositionAndCreate(pDlgData,
    1870                                              &szlClient,
    1871                                              &hwndFocusItem);
    1872 
    1873                 /*
    1874                  *  7) WM_INITDLG, set focus
    1875                  *
    1876                  */
    1877 
    1878                 if (!WinSendMsg(pDlgData->hwndDlg,
    1879                                 WM_INITDLG,
    1880                                 (MPARAM)hwndFocusItem,
    1881                                 (MPARAM)pCreateParams))
     1845                if (!(arc = Dlg2_CalcSizes(pDlgData,
     1846                                           &szlClient)))
    18821847                {
    1883                     // if WM_INITDLG returns FALSE, this means
    1884                     // the dlg proc has not changed the focus;
    1885                     // we must then set the focus here
    1886                     WinSetFocus(HWND_DESKTOP, hwndFocusItem);
     1848                    WinSubclassWindow(hwndDlg, pfnwpDialogProc);
     1849
     1850                    /*
     1851                     *  4) compute size of dialog client from total
     1852                     *     size of all controls
     1853                     */
     1854
     1855                    // calculate the frame size from the client size
     1856                    rclClient.xLeft = 10;
     1857                    rclClient.yBottom = 10;
     1858                    rclClient.xRight = szlClient.cx + 2 * SPACING;
     1859                    rclClient.yTop = szlClient.cy + 2 * SPACING;
     1860                    WinCalcFrameRect(hwndDlg,
     1861                                     &rclClient,
     1862                                     FALSE);            // frame from client
     1863
     1864                    WinSetWindowPos(hwndDlg,
     1865                                    0,
     1866                                    10,
     1867                                    10,
     1868                                    rclClient.xRight,
     1869                                    rclClient.yTop,
     1870                                    SWP_MOVE | SWP_SIZE | SWP_NOADJUST);
     1871
     1872                    arc = Dlg3_PositionAndCreate(pDlgData,
     1873                                                 &szlClient,
     1874                                                 &hwndFocusItem);
     1875
     1876                    /*
     1877                     *  7) WM_INITDLG, set focus
     1878                     *
     1879                     */
     1880
     1881                    if (!WinSendMsg(pDlgData->hwndDlg,
     1882                                    WM_INITDLG,
     1883                                    (MPARAM)hwndFocusItem,
     1884                                    (MPARAM)pCreateParams))
     1885                    {
     1886                        // if WM_INITDLG returns FALSE, this means
     1887                        // the dlg proc has not changed the focus;
     1888                        // we must then set the focus here
     1889                        WinSetFocus(HWND_DESKTOP, hwndFocusItem);
     1890                    }
    18871891                }
    18881892            }
     
    19531957
    19541958APIRET dlghFormatDlg(HWND hwndDlg,              // in: dialog frame to work on
    1955                      PDLGHITEM paDlgItems,      // in: definition array
     1959                     PCDLGHITEM paDlgItems,      // in: definition array
    19561960                     ULONG cDlgItems,           // in: array item count (NOT array size)
    1957                      const char *pcszControlsFont, // in: font for ctls with CTL_COMMON_FONT
     1961                     PCSZ pcszControlsFont, // in: font for ctls with CTL_COMMON_FONT
    19581962                     ULONG flFlags)             // in: DFFL_* flags
    19591963{
     
    22092213
    22102214APIRET dlghAppendToArray(PDLGARRAY pArray,      // in: dialog array created by dlghCreateArray
    2211                          DLGHITEM *paItems,     // in: subarray to be appended
     2215                         PCDLGHITEM paItems,     // in: subarray to be appended
    22122216                         ULONG cItems)          // in: subarray item count (NOT array size)
    22132217{
     
    22502254                            HWND hwndOwner,
    22512255                            HPOINTER hptrIcon,
    2252                             const char *pcszTitle,
    2253                             const char *pcszMessage,
     2256                            PCSZ pcszTitle,
     2257                            PCSZ pcszMessage,
    22542258                            ULONG flFlags,
    2255                             const char *pcszFont,
     2259                            PCSZ pcszFont,
    22562260                            const MSGBOXSTRINGS *pStrings,
    22572261                            PULONG pulAlarmFlag)      // out: alarm sound to be played
     
    23342338                *p2 = NULL;
    23352339
    2336     Icon.pcszText = (const char *)hptrIcon;
     2340    Icon.pcszText = (PCSZ)hptrIcon;
    23372341    InfoText.pcszText = pcszMessage;
    23382342
     
    25452549ULONG dlghMessageBox(HWND hwndOwner,            // in: owner for msg box
    25462550                     HPOINTER hptrIcon,         // in: icon to display
    2547                      const char *pcszTitle,     // in: title
    2548                      const char *pcszMessage,   // in: message
     2551                     PCSZ pcszTitle,     // in: title
     2552                     PCSZ pcszMessage,   // in: message
    25492553                     ULONG flFlags,             // in: standard message box flags
    2550                      const char *pcszFont,      // in: font (e.g. "9.WarpSans")
     2554                     PCSZ pcszFont,      // in: font (e.g. "9.WarpSans")
    25512555                     const MSGBOXSTRINGS *pStrings) // in: strings array
    25522556{
     
    26162620
    26172621PSZ dlghTextEntryBox(HWND hwndOwner,
    2618                      const char *pcszTitle,          // in: dlg title
    2619                      const char *pcszDescription,    // in: descriptive text above entry field
    2620                      const char *pcszDefault,        // in: default text for entry field or NULL
    2621                      const char *pcszOK,             // in: "OK" string
    2622                      const char *pcszCancel,         // in: "Cancel" string
     2622                     PCSZ pcszTitle,          // in: dlg title
     2623                     PCSZ pcszDescription,    // in: descriptive text above entry field
     2624                     PCSZ pcszDefault,        // in: default text for entry field or NULL
     2625                     PCSZ pcszOK,             // in: "OK" string
     2626                     PCSZ pcszCancel,         // in: "Cancel" string
    26232627                     ULONG ulMaxLen,                 // in: maximum length for entry
    26242628                     ULONG fl,                       // in: TEBF_* flags
    2625                      const char *pcszFont)           // in: font (e.g. "9.WarpSans")
     2629                     PCSZ pcszFont)           // in: font (e.g. "9.WarpSans")
    26262630{
    26272631    CONTROLDEF
  • trunk/src/helpers/dosh.c

    r131 r132  
    23822382                    pszContent[cbRead] = '\0';
    23832383                    *ppszContent = pszContent;
     2384                    if (pcbRead)
     2385                        *pcbRead = cbRead + 1;
    23842386                }
    23852387            }
     
    29782980
    29792981/*
     2982 *@@ doshQueryProcAddr:
     2983 *      attempts to resolve the given procedure from
     2984 *      the given module name. Saves you from querying
     2985 *      the module handle and all that.
     2986 *
     2987 *      This is intended for resolving undocumented
     2988 *      APIs from OS/2 system DLls such as PMMERGE
     2989 *      and DOSCALLS. It is assumed that the specified
     2990 *      module is already loaded.
     2991 *
     2992 *      Returns:
     2993 *
     2994 *      --  NO_ERROR
     2995 *
     2996 *      --  ERROR_INVALID_NAME
     2997 *
     2998 *      --  ERROR_INVALID_ORDINAL
     2999 *
     3000 *      plus the error codes of DosLoadModule.
     3001 *
     3002 *@@added V0.9.16 (2002-01-13) [umoeller]
     3003 */
     3004
     3005APIRET doshQueryProcAddr(PCSZ pcszModuleName,       // in: module name (e.g. "PMMERGE")
     3006                         ULONG ulOrdinal,           // in: proc ordinal
     3007                         PFN *ppfn)                 // out: proc address
     3008{
     3009    HMODULE hmod;
     3010    APIRET  arc;
     3011    if (!(arc = DosQueryModuleHandle((PSZ)pcszModuleName,
     3012                                     &hmod)))
     3013    {
     3014        if ((arc = DosQueryProcAddr(hmod,
     3015                                    ulOrdinal,
     3016                                    NULL,
     3017                                    ppfn)))
     3018        {
     3019            // the CP programming guide and reference says use
     3020            // DosLoadModule if DosQueryProcAddr fails with this error
     3021            if (arc == ERROR_INVALID_HANDLE)
     3022            {
     3023                if (!(arc = DosLoadModule(NULL,
     3024                                          0,
     3025                                          (PSZ)pcszModuleName,
     3026                                          &hmod)))
     3027                {
     3028                    arc = DosQueryProcAddr(hmod,
     3029                                           ulOrdinal,
     3030                                           NULL,
     3031                                           ppfn);
     3032                }
     3033            }
     3034        }
     3035    }
     3036
     3037    return (arc);
     3038}
     3039
     3040/*
    29803041 *@@ doshResolveImports:
    29813042 *      this function loads the module called pszModuleName
     
    29903051 */
    29913052
    2992 APIRET doshResolveImports(PSZ pszModuleName,    // in: DLL to load
     3053APIRET doshResolveImports(PCSZ pcszModuleName,    // in: DLL to load
    29933054                          HMODULE *phmod,       // out: module handle
    2994                           PRESOLVEFUNCTION paResolves, // in/out: function resolves
     3055                          PCRESOLVEFUNCTION paResolves, // in/out: function resolves
    29953056                          ULONG cResolves)      // in: array item count (not array size!)
    29963057{
     
    30003061    if (!(arc = DosLoadModule(szName,
    30013062                              sizeof(szName),
    3002                               pszModuleName,
     3063                              (PSZ)pcszModuleName,
    30033064                              phmod)))
    30043065    {
  • trunk/src/helpers/exeh.c

    r131 r132  
    329329                // go read in the complete header then
    330330                // (doshReadAt has this in the cache)
    331                 if (!(pExec->pNEHeader = malloc(cbRead)))
     331                if (!(pExec->pNEHeader = (PNEHEADER)malloc(cbRead)))
    332332                    arc = ERROR_NOT_ENOUGH_MEMORY;
    333333                else if (!(arc = doshReadAt(pFile,
     
    361361                // go read in the complete header then
    362362                // (doshReadAt has this in the cache)
    363                 if (!(pExec->pLXHeader = malloc(cbRead)))
     363                if (!(pExec->pLXHeader = (PLXHEADER)malloc(cbRead)))
    364364                    arc = ERROR_NOT_ENOUGH_MEMORY;
    365365                else if (!(arc = doshReadAt(pFile,
     
    389389                // plus an extended header, so check
    390390                // what we've got
    391                 if (!(pExec->pPEHeader = malloc(sizeof(PEHEADER))))
     391                if (!(pExec->pPEHeader = (PPEHEADER)malloc(sizeof(PEHEADER))))
    392392                    arc = ERROR_NOT_ENOUGH_MEMORY;
    393393                else
     
    27422742                    // 4096 bytes for each page that is read in
    27432743                    // plus 4 extra bytes to terminate for decompression
    2744                     if (!(pabCompressed = malloc(ulPageSize + 4)))
     2744                    if (!(pabCompressed = (PBYTE)malloc(ulPageSize + 4)))
    27452745                        arc = ERROR_NOT_ENOUGH_MEMORY;
    27462746                    // 4096 * cPages for the data that is composed from that
     
    27932793                        {
    27942794                            // allocate a new buffer for caller
    2795                             if (!(*ppbResData = malloc(pRsEntry->cb)))
     2795                            if (!(*ppbResData = (PBYTE)malloc(pRsEntry->cb)))
    27962796                                arc = ERROR_NOT_ENOUGH_MEMORY;
    27972797                            else
     
    30523052                ULONG cb = pSegThis->ns_cbseg;        // resource size
    30533053                PBYTE pb;
    3054                 if (!(*ppbResData = malloc(cb)))
     3054                if (!(*ppbResData = (PBYTE)malloc(cb)))
    30553055                    arc = ERROR_NOT_ENOUGH_MEMORY;
    30563056                else
  • trunk/src/helpers/linklist.c

    r113 r132  
    292292                                            // item pointers upon destruction?
    293293{
    294     PLINKLIST pNewList = (PLINKLIST)malloc(sizeof(LINKLIST));
    295     if (pNewList)
     294    PLINKLIST pNewList;
     295    if (pNewList = (PLINKLIST)malloc(sizeof(LINKLIST)))
    296296        lstInit(pNewList, fItemsFreeable);
    297297    return (pNewList);
     
    444444    PLISTNODE pNode = NULL;
    445445
    446     if (pList)
    447         if (pList->ulMagic == LINKLISTMAGIC)
    448             if (pList->pFirst)
    449             {
    450                 unsigned long ulCount = 0;
    451                 pNode = pList->pFirst;
    452                 for (ulCount = 0;
    453                      ((pNode) && (ulCount < ulIndex));
    454                      ulCount++)
    455                 {
    456                     if (pNode->pNext)
    457                         pNode = pNode->pNext;
    458                     else
    459                         pNode = NULL; // exit
    460                 }
    461             }
     446    if (    (pList)
     447         && (pList->ulMagic == LINKLISTMAGIC)
     448         && (pList->pFirst)
     449       )
     450    {
     451        unsigned long ulCount = 0;
     452        pNode = pList->pFirst;
     453        for (ulCount = 0;
     454             ((pNode) && (ulCount < ulIndex));
     455             ulCount++)
     456        {
     457            if (pNode->pNext)
     458                pNode = pNode->pNext;
     459            else
     460                pNode = NULL; // exit
     461        }
     462    }
    462463
    463464    return (pNode);
     
    480481              pNodeFound = 0;
    481482
    482     if (pList)
    483         if (    (pList->ulMagic == LINKLISTMAGIC)
    484              && (pItemData)
    485            )
    486         {
    487             pNode = pList->pFirst;
    488             while (pNode)
     483    if (    (pList)
     484         && (pList->ulMagic == LINKLISTMAGIC)
     485         && (pItemData)
     486       )
     487    {
     488        pNode = pList->pFirst;
     489        while (pNode)
     490        {
     491            if (pNode->pItemData == pItemData)
    489492            {
    490                 if (pNode->pItemData == pItemData)
    491                 {
    492                     pNodeFound = pNode;
    493                     break;
    494                 }
    495 
    496                 pNode = pNode->pNext;
     493                pNodeFound = pNode;
     494                break;
    497495            }
    498         }
     496
     497            pNode = pNode->pNext;
     498        }
     499    }
    499500
    500501    return (pNodeFound);
     
    518519                       unsigned long ulIndex)
    519520{
    520     PLISTNODE pNode = lstNodeFromIndex(pList, ulIndex);
    521     if (pNode)
     521    PLISTNODE pNode;
     522    if (pNode = lstNodeFromIndex(pList, ulIndex))
    522523        return (pNode->pItemData);
    523524    else
     
    580581                             const char *function)
    581582{
    582     PLISTNODE pNewNode = 0;
    583 
    584     if (pList)
    585         if (pList->ulMagic == LINKLISTMAGIC)
    586         {
    587             if (pNewNode = (PLISTNODE)memdMalloc(sizeof(LISTNODE), file, line, function))
    588             {
    589                 memset(pNewNode, 0, sizeof(LISTNODE));
    590                 pNewNode->pItemData = pNewItemData;
    591 
    592                 if (pList->pLast)
    593                 {
    594                     // list is not empty: append to tail
    595 
    596                     // 1) make last item point to new node
    597                     pList->pLast->pNext = pNewNode;
    598                     // 2) make new node point to last item
    599                     pNewNode->pPrevious = pList->pLast;
    600                     // 3) store new node as new last item
    601                     pList->pLast = pNewNode;
    602 
    603                     pList->ulCount++;
    604                 }
    605                 else
    606                 {
    607                     // list is empty: insert as first
    608                     pList->pFirst
    609                         = pList->pLast
    610                         = pNewNode;
    611 
    612                     pList->ulCount = 1;
    613                 }
    614             }
    615          }
     583    PLISTNODE pNewNode = NULL;
     584
     585    if (    (pList)
     586         && (pList->ulMagic == LINKLISTMAGIC)
     587         && (pNewNode = (PLISTNODE)memdMalloc(sizeof(LISTNODE), file, line, function))
     588       )
     589    {
     590        memset(pNewNode, 0, sizeof(LISTNODE));
     591        pNewNode->pItemData = pNewItemData;
     592
     593        if (pList->pLast)
     594        {
     595            // list is not empty: append to tail
     596
     597            // 1) make last item point to new node
     598            pList->pLast->pNext = pNewNode;
     599            // 2) make new node point to last item
     600            pNewNode->pPrevious = pList->pLast;
     601            // 3) store new node as new last item
     602            pList->pLast = pNewNode;
     603
     604            pList->ulCount++;
     605        }
     606        else
     607        {
     608            // list is empty: insert as first
     609            pList->pFirst
     610                = pList->pLast
     611                = pNewNode;
     612
     613            pList->ulCount = 1;
     614        }
     615    }
    616616
    617617    return (pNewNode);
     
    635635                        void* pNewItemData)     // in: data to store in list node
    636636{
    637     PLISTNODE pNewNode = 0;
    638 
    639     if (pList)
    640         if (pList->ulMagic == LINKLISTMAGIC)
    641         {
    642             if (pNewNode = (PLISTNODE)malloc(sizeof(LISTNODE)))
    643             {
    644                 memset(pNewNode, 0, sizeof(LISTNODE));
    645                 pNewNode->pItemData = pNewItemData;
    646 
    647                 if (pList->pLast)
    648                 {
    649                     // list is not empty: append to tail
    650 
    651                     // 1) make last item point to new node
    652                     pList->pLast->pNext = pNewNode;
    653                     // 2) make new node point to last item
    654                     pNewNode->pPrevious = pList->pLast;
    655                     // 3) store new node as new last item
    656                     pList->pLast = pNewNode;
    657 
    658                     pList->ulCount++;
    659                 }
    660                 else
    661                 {
    662                     // list is empty: insert as first
    663                     pList->pFirst
    664                         = pList->pLast
    665                         = pNewNode;
    666 
    667                     pList->ulCount = 1;
    668                 }
    669             }
    670          }
     637    PLISTNODE pNewNode = NULL;
     638
     639    if (    (pList)
     640         && (pList->ulMagic == LINKLISTMAGIC)
     641         && (pNewNode = (PLISTNODE)malloc(sizeof(LISTNODE)))
     642       )
     643    {
     644        memset(pNewNode, 0, sizeof(LISTNODE));
     645        pNewNode->pItemData = pNewItemData;
     646
     647        if (pList->pLast)
     648        {
     649            // list is not empty: append to tail
     650
     651            // 1) make last item point to new node
     652            pList->pLast->pNext = pNewNode;
     653            // 2) make new node point to last item
     654            pNewNode->pPrevious = pList->pLast;
     655            // 3) store new node as new last item
     656            pList->pLast = pNewNode;
     657
     658            pList->ulCount++;
     659        }
     660        else
     661        {
     662            // list is empty: insert as first
     663            pList->pFirst
     664                = pList->pLast
     665                = pNewNode;
     666
     667            pList->ulCount = 1;
     668        }
     669    }
    671670
    672671    return (pNewNode);
     
    703702                              unsigned long ulIndex)
    704703{
    705     PLISTNODE pNewNode = 0;
    706 
    707     if (pList)
    708         if (pList->ulMagic == LINKLISTMAGIC)
    709         {
    710             if (pNewNode = (PLISTNODE)malloc(sizeof(LISTNODE)))
     704    PLISTNODE pNewNode = NULL;
     705
     706    if (    (pList)
     707         && (pList->ulMagic == LINKLISTMAGIC)
     708         && (pNewNode = (PLISTNODE)malloc(sizeof(LISTNODE)))
     709       )
     710    {
     711        memset(pNewNode, 0, sizeof(LISTNODE));
     712        pNewNode->pItemData = pNewItemData;
     713
     714        if (ulIndex == 0)
     715        {
     716            // insert at beginning:
     717            if (pList->pFirst)
     718                pList->pFirst->pPrevious = pNewNode;
     719
     720            pNewNode->pNext = pList->pFirst;
     721            pNewNode->pPrevious = NULL;
     722
     723            pList->pFirst = pNewNode;
     724
     725            if (!pList->pLast)
     726                // the list was empty:
     727                pList->pLast = pNewNode;        // V0.9.14 (2001-07-14) [umoeller]
     728
     729            (pList->ulCount)++;
     730        }
     731        else
     732        {
     733            // insert at a later position:
     734            PLISTNODE pNodeInsertAfter = lstNodeFromIndex(
     735                                    pList,
     736                                    (ulIndex-1));
     737
     738            if (pNodeInsertAfter)
    711739            {
    712                 memset(pNewNode, 0, sizeof(LISTNODE));
    713                 pNewNode->pItemData = pNewItemData;
    714 
    715                 if (ulIndex == 0)
    716                 {
    717                     // insert at beginning:
    718                     if (pList->pFirst)
    719                         pList->pFirst->pPrevious = pNewNode;
    720 
    721                     pNewNode->pNext = pList->pFirst;
    722                     pNewNode->pPrevious = NULL;
    723 
    724                     pList->pFirst = pNewNode;
    725 
    726                     if (!pList->pLast)
    727                         // the list was empty:
    728                         pList->pLast = pNewNode;        // V0.9.14 (2001-07-14) [umoeller]
    729 
    730                     (pList->ulCount)++;
    731                 }
    732                 else
    733                 {
    734                     // insert at a later position:
    735                     PLISTNODE pNodeInsertAfter = lstNodeFromIndex(
    736                                             pList,
    737                                             (ulIndex-1));
    738 
    739                     if (pNodeInsertAfter)
    740                     {
    741                         // 1) set pointers for new node
    742                         pNewNode->pPrevious = pNodeInsertAfter;
    743                         pNewNode->pNext = pNodeInsertAfter->pNext;
    744 
    745                         // 2) adjust next item
    746                         // so that it points to the new node
    747                         if (pNodeInsertAfter->pNext)
    748                             pNodeInsertAfter->pNext->pPrevious = pNewNode;
    749 
    750                         // 3) adjust previous item
    751                         // so that it points to the new node
    752                         pNodeInsertAfter->pNext = pNewNode;
    753 
    754                         // 4) adjust last item, if necessary
    755                         if (pList->pLast == pNodeInsertAfter)
    756                             pList->pLast = pNewNode;
    757 
    758                         (pList->ulCount)++;
    759                     }
    760                     else
    761                     {
    762                         // item index too large: append instead
    763                         free(pNewNode);
    764                         pNewNode = lstAppendItem(pList, pNewItemData);
    765                     }
    766                 }
     740                // 1) set pointers for new node
     741                pNewNode->pPrevious = pNodeInsertAfter;
     742                pNewNode->pNext = pNodeInsertAfter->pNext;
     743
     744                // 2) adjust next item
     745                // so that it points to the new node
     746                if (pNodeInsertAfter->pNext)
     747                    pNodeInsertAfter->pNext->pPrevious = pNewNode;
     748
     749                // 3) adjust previous item
     750                // so that it points to the new node
     751                pNodeInsertAfter->pNext = pNewNode;
     752
     753                // 4) adjust last item, if necessary
     754                if (pList->pLast == pNodeInsertAfter)
     755                    pList->pLast = pNewNode;
     756
     757                (pList->ulCount)++;
    767758            }
    768         }
     759            else
     760            {
     761                // item index too large: append instead
     762                free(pNewNode);
     763                pNewNode = lstAppendItem(pList, pNewItemData);
     764            }
     765        }
     766    }
    769767
    770768    return (pNewNode);
     
    797795    BOOL fFound = FALSE;
    798796
    799     if (pList)
    800         if (    (pList->ulMagic == LINKLISTMAGIC)
    801              && (pRemoveNode)
    802            )
    803         {
    804             if (pList->pFirst == pRemoveNode)
    805                 // item to be removed is first: adjust first
    806                 pList->pFirst = pRemoveNode->pNext;     // can be NULL
    807             if (pList->pLast == pRemoveNode)
    808                 // item to be removed is last: adjust last
    809                 pList->pLast = pRemoveNode->pPrevious;  // can be NULL
    810 
    811             if (pRemoveNode->pPrevious)
    812                 // adjust previous item
    813                 pRemoveNode->pPrevious->pNext = pRemoveNode->pNext;
    814 
    815             if (pRemoveNode->pNext)
    816                 // adjust next item
    817                 pRemoveNode->pNext->pPrevious = pRemoveNode->pPrevious;
    818 
    819             // decrease list count
    820             pList->ulCount--;
    821 
    822             // free node data
    823             if (pList->fItemsFreeable)
    824                 if (pRemoveNode->pItemData)
    825                     free(pRemoveNode->pItemData);
    826             // free node
    827             free(pRemoveNode);
    828 
    829             fFound = TRUE;
    830         }
     797    if (    (pList)
     798         && (pList->ulMagic == LINKLISTMAGIC)
     799         && (pRemoveNode)
     800       )
     801    {
     802        if (pList->pFirst == pRemoveNode)
     803            // item to be removed is first: adjust first
     804            pList->pFirst = pRemoveNode->pNext;     // can be NULL
     805        if (pList->pLast == pRemoveNode)
     806            // item to be removed is last: adjust last
     807            pList->pLast = pRemoveNode->pPrevious;  // can be NULL
     808
     809        if (pRemoveNode->pPrevious)
     810            // adjust previous item
     811            pRemoveNode->pPrevious->pNext = pRemoveNode->pNext;
     812
     813        if (pRemoveNode->pNext)
     814            // adjust next item
     815            pRemoveNode->pNext->pPrevious = pRemoveNode->pPrevious;
     816
     817        // decrease list count
     818        pList->ulCount--;
     819
     820        // free node data
     821        if (pList->fItemsFreeable)
     822            if (pRemoveNode->pItemData)
     823                free(pRemoveNode->pItemData);
     824        // free node
     825        free(pRemoveNode);
     826
     827        fFound = TRUE;
     828    }
    831829
    832830    return (fFound);
     
    852850BOOL lstRemoveItem(PLINKLIST pList, void* pRemoveItem)
    853851{
    854     BOOL brc = FALSE;
    855 
    856     PLISTNODE pNode = lstNodeFromItem(pList, pRemoveItem);
    857 
    858     if (pNode)
    859         brc = lstRemoveNode(pList, pNode);
    860 
    861     return (brc);
     852    PLISTNODE pNode;
     853
     854    if (pNode = lstNodeFromItem(pList, pRemoveItem))
     855        return (lstRemoveNode(pList, pNode));
     856
     857    return (FALSE);
    862858}
    863859
     
    875871                  PLISTNODE pNode2)
    876872{
    877     BOOL brc = FALSE;
    878 
    879873    if ( (pNode1) && (pNode2) )
    880874    {
     
    883877        pNode2->pItemData = pTemp;
    884878
    885         brc = TRUE;
     879        return (TRUE);
    886880    }
    887881
    888     return (brc);
     882    return (FALSE);
    889883}
    890884
     
    907901{
    908902    long ll = lLeft,
    909          lr = lRight-1,
     903         lr = lRight - 1,
    910904         lPivot = lRight;
    911905
     
    919913        {
    920914            // compare left item data to pivot item data
    921             while ( (*pfnSort)(pNodeLeft->pItemData,
    922                                pNodePivot->pItemData,
    923                                pStorage)
     915            while ( pfnSort(pNodeLeft->pItemData,
     916                            pNodePivot->pItemData,
     917                            pStorage)
    924918                    < 0 )
    925919            {
     
    930924
    931925            // compare right item to pivot
    932             while (     ( (*pfnSort)(pNodeRight->pItemData,
    933                                      pNodePivot->pItemData,
    934                                      pStorage)
     926            while (     ( pfnSort(pNodeRight->pItemData,
     927                                  pNodePivot->pItemData,
     928                                  pStorage)
    935929                           >= 0 )
    936930                    && (lr > ll)
     
    953947
    954948        // recurse!
    955         lstQuickSort2(pList, pfnSort, pStorage, lLeft, ll-1);
    956         lstQuickSort2(pList, pfnSort, pStorage, ll+1, lRight);
     949        lstQuickSort2(pList, pfnSort, pStorage,
     950                      lLeft,
     951                      ll - 1);
     952        lstQuickSort2(pList, pfnSort, pStorage,
     953                      ll + 1,
     954                      lRight);
    957955    }
    958956}
     
    994992    BOOL brc = FALSE;
    995993
    996     if (pList)
    997         if (    (pList->ulMagic == LINKLISTMAGIC)
    998              && (pfnSort)
    999            )
    1000         {
    1001             long lRight = lstCountItems(pList)-1;
    1002 
    1003             lstQuickSort2(pList, pfnSort, pStorage,
    1004                         0,          // lLeft
    1005                         lRight);
    1006             brc = TRUE;
    1007         }
     994    if (    (pList)
     995         && (pList->ulMagic == LINKLISTMAGIC)
     996         && (pfnSort)
     997       )
     998    {
     999        long lRight = lstCountItems(pList) - 1;
     1000
     1001        lstQuickSort2(pList, pfnSort, pStorage,
     1002                      0,          // lLeft
     1003                      lRight);
     1004        brc = TRUE;
     1005    }
    10081006
    10091007    return (brc);
  • trunk/src/helpers/memdebug.c

    r123 r132  
    753753                                             //     before each output line
    754754    {
    755         PSZ psz = strhCreateDump(pb, ulSize, ulIndent);
    756         if (psz)
     755        PSZ psz;
     756        if (psz = strhCreateDump(pb, ulSize, ulIndent))
    757757        {
    758             _Pmpf(("\n%s", psz));
     758            // _Pmpf(("\n%s", psz));
    759759            free(psz);
    760760        }
  • trunk/src/helpers/stringh.c

    r127 r132  
    347347 *@@ strhncpy0:
    348348 *      like strncpy, but always appends a 0 character.
     349 *
     350 *@@changed V0.9.16 (2002-01-09) [umoeller]: fixed crash on null pszSource
    349351 */
    350352
     
    354356{
    355357    ULONG ul = 0;
    356     PSZ pTarget = pszTarget,
    357         pSource = (PSZ)pszSource;
    358 
    359     for (ul = 0; ul < cbSource; ul++)
    360         if (*pSource)
    361             *pTarget++ = *pSource++;
    362         else
    363             break;
     358    PSZ     pTarget = pszTarget,
     359            pSource;
     360
     361    if (pSource = (PSZ)pszSource)       // V0.9.16 (2002-01-09) [umoeller]
     362    {
     363        for (ul = 0; ul < cbSource; ul++)
     364            if (*pSource)
     365                *pTarget++ = *pSource++;
     366            else
     367                break;
     368    }
     369
    364370    *pTarget = 0;
    365371
     
    529535    if (pszBuf)
    530536    {
    531         PSZ pOpen = strchr(pszBuf, cOpen);
    532         if (pOpen)
     537        PSZ pOpen;
     538        if (pOpen = strchr(pszBuf, cOpen))
    533539        {
    534540            // opening char found:
  • trunk/src/helpers/threads.c

    r123 r132  
    501501        PLISTNODE pNode;
    502502        *pcThreads = lstCountItems(&G_llThreadInfos);
    503         pArray = (PTHREADINFO)malloc(*pcThreads * sizeof(THREADINFO));
    504         pThis = pArray;
    505 
    506         pNode = lstQueryFirstNode(&G_llThreadInfos);
    507         while (pNode)
     503        if (pArray = (PTHREADINFO)malloc(*pcThreads * sizeof(THREADINFO)))
    508504        {
    509             memcpy(pThis,
    510                    (PTHREADINFO)pNode->pItemData,
    511                    sizeof(THREADINFO));
    512             pThis++;
    513             pNode = pNode->pNext;
     505            pThis = pArray;
     506
     507            pNode = lstQueryFirstNode(&G_llThreadInfos);
     508            while (pNode)
     509            {
     510                memcpy(pThis,
     511                       (PTHREADINFO)pNode->pItemData,
     512                       sizeof(THREADINFO));
     513                pThis++;
     514                pNode = pNode->pNext;
     515            }
    514516        }
    515517
  • trunk/src/helpers/winh.c

    r129 r132  
    45104510            HWND hwndStatusBar = winhCreateStatusBar(hwndFrame,
    45114511                                                     hwndFrame,
    4512                                                      NULL,
     4512                                                     "",
    45134513                                                     "9.WarpSans",
    45144514                                                     CLR_BLACK);
  • trunk/src/helpers/xstring.c

    r129 r132  
    129129void XWPENTRY xstrInitDebug(PXSTRING pxstr,
    130130                            ULONG ulPreAllocate,
    131                             const char *file,
     131                            PCSZ file,
    132132                            unsigned long line,
    133                             const char *function)
     133                            PCSZ function)
    134134{
    135135    memset(pxstr, 0, sizeof(XSTRING));
     
    194194
    195195/*
    196  *@@ xstrInitSet:
     196 *@@ xstrInitSet2:
    197197 *      this can be used instead of xstrInit if you
    198198 *      have a free()'able string you want to initialize
     
    212212 +          xstrInitSet(&str, strdup("blah"));
    213213 *
    214  *@@added V0.9.6 (2000-11-01) [umoeller]
    215  *@@changed V0.9.9 (2001-03-09) [umoeller]: added ulDelta
    216  */
    217 
    218 void xstrInitSet(PXSTRING pxstr,
    219                  PSZ pszNew)
     214 *@@added V0.9.16 (2002-01-13) [umoeller]
     215 */
     216
     217void xstrInitSet2(PXSTRING pxstr,
     218                  PSZ pszNew,
     219                  ULONG ulNewLength)
    220220{
    221221    if (!pszNew)
     
    223223    else
    224224    {
     225        if (!ulNewLength)
     226            ulNewLength = strlen(pszNew);
    225227        pxstr->psz = pszNew;
    226         pxstr->ulLength = strlen(pszNew);
    227         pxstr->cbAllocated = pxstr->ulLength + 1;
    228         pxstr->ulDelta = pxstr->ulLength  * 10 / 100;
    229     }
     228        pxstr->ulLength = ulNewLength;
     229        pxstr->cbAllocated = ulNewLength + 1;
     230        pxstr->ulDelta = ulNewLength * 10 / 100;
     231    }
     232}
     233
     234/*
     235 *@@ xstrInitSet:
     236 *      shortcut to xstrInitSet2 to retain compatibility.
     237 *
     238 *@@added V0.9.6 (2000-11-01) [umoeller]
     239 *@@changed V0.9.9 (2001-03-09) [umoeller]: added ulDelta
     240 */
     241
     242void xstrInitSet(PXSTRING pxstr,
     243                 PSZ pszNew)
     244{
     245    xstrInitSet2(pxstr, pszNew, 0);
    230246}
    231247
     
    239255
    240256void XWPENTRY xstrInitCopyDebug(PXSTRING pxstr,
    241                                 const char *pcszSource,
     257                                PCSZ pcszSource,
    242258                                ULONG ulExtraAllocate,
    243                                 const char *file,
     259                                PCSZ file,
    244260                                unsigned long line,
    245                                 const char *function)
     261                                PCSZ function)
    246262{
    247263    if (pxstr)
     
    301317
    302318void xstrInitCopy(PXSTRING pxstr,
    303                   const char *pcszSource,
     319                  PCSZ pcszSource,
    304320                  ULONG ulExtraAllocate)          // in: if > 0, extra memory to allocate
    305321{
     
    497513
    498514/*
    499  *@@ xstrset:
     515 *@@ xstrset2:
    500516 *      sets the specified XSTRING to a new string
    501517 *      without copying it.
     
    511527 *      is true if pszNew comes from strdup().
    512528 *
    513  *@@added V0.9.6 (2000-11-01) [umoeller]
    514  *@@changed V0.9.9 (2001-02-14) [umoeller]: fixed NULL target crash
    515  */
    516 
    517 ULONG xstrset(PXSTRING pxstr,               // in/out: string
    518               PSZ pszNew)                   // in: heap PSZ to use
     529 *      With this function, you can pass in the
     530 *      length of the string in ulNewLength.
     531 *      Otherwise use xstrset.
     532 *
     533 *@@added V0.9.16 (2002-01-13) [umoeller]
     534 */
     535
     536ULONG xstrset2(PXSTRING pxstr,              // in/out: string
     537               PSZ pszNew,                  // in: heap PSZ to use
     538               ULONG ulNewLength)           // in: length of string or 0 to run strlen here
    519539{
    520540    if (!pxstr)
     
    525545    if (pszNew)
    526546    {
    527         pxstr->ulLength = strlen(pszNew);
    528         pxstr->cbAllocated = pxstr->ulLength + 1;
    529 
    530         pxstr->ulDelta = pxstr->cbAllocated * 10 / 100;
     547        if (!ulNewLength)
     548            ulNewLength = strlen(pszNew);
     549        pxstr->ulLength = ulNewLength;
     550        pxstr->cbAllocated = ulNewLength + 1;
     551
     552        pxstr->ulDelta = ulNewLength * 10 / 100;
    531553    }
    532554    // else null string: cbAllocated and ulLength are 0 already
    533555
    534556    return (pxstr->ulLength);
     557}
     558
     559/*
     560 *@@ xstrset:
     561 *      shortcut for xstrset2 for retaining compatibility.
     562 *
     563 *@@added V0.9.6 (2000-11-01) [umoeller]
     564 *@@changed V0.9.9 (2001-02-14) [umoeller]: fixed NULL target crash
     565 */
     566
     567ULONG xstrset(PXSTRING pxstr,               // in/out: string
     568              PSZ pszNew)                   // in: heap PSZ to use
     569{
     570    return (xstrset2(pxstr, pszNew, 0));
    535571}
    536572
     
    583619
    584620ULONG xstrcpy(PXSTRING pxstr,               // in/out: string
    585               const char *pcszSource,       // in: source, can be NULL
     621              PCSZ pcszSource,       // in: source, can be NULL
    586622              ULONG ulSourceLength)         // in: length of pcszSource or 0
    587623{
     
    694730
    695731ULONG xstrcat(PXSTRING pxstr,               // in/out: string
    696               const char *pcszSource,       // in: source, can be NULL
     732              PCSZ pcszSource,       // in: source, can be NULL
    697733              ULONG ulSourceLength)         // in: length of pcszSource or 0
    698734{
     
    863899              ULONG ulFirstReplOfs,             // in: ofs of first char to replace
    864900              ULONG cReplLen,                   // in: no. of chars to replace
    865               const char *pcszReplaceWith,      // in: string to replace chars with
     901              PCSZ pcszReplaceWith,      // in: string to replace chars with
    866902              ULONG cReplaceWithLen)            // in: length of replacement string
    867903                                                // (this MUST be specified; if 0, chars are removed only)
     
    10141050                 size_t *pShiftTable,         // in: shift table (see strhmemfind)
    10151051                 PBOOL pfRepeatFind,          // in: repeat find? (see strhmemfind)
    1016                  const char *pcszBeginChars,  // suggestion: "\x0d\x0a ()/\\-,."
    1017                  const char *pcszEndChars)    // suggestion: "\x0d\x0a ()/\\-,.:;"
     1052                 PCSZ pcszBeginChars,  // suggestion: "\x0d\x0a ()/\\-,."
     1053                 PCSZ pcszEndChars)    // suggestion: "\x0d\x0a ()/\\-,.:;"
    10181054{
    10191055    PSZ     pReturn = 0;
     
    10251061        if ((pxstr->ulLength) && (ulFoundLen))
    10261062        {
    1027             const char *p = pxstr->psz + ulOfs;
     1063            PCSZ p = pxstr->psz + ulOfs;
    10281064
    10291065            do  // while p
     
    11521188            // yes:
    11531189            ULONG   ulOfs = *pulOfs;
    1154             const char *pFound
    1155                 = (const char *)strhmemfind(pxstr->psz + ulOfs, // in: haystack
     1190            PCSZ pFound
     1191                = (PCSZ)strhmemfind(pxstr->psz + ulOfs, // in: haystack
    11561192                                            pxstr->ulLength - ulOfs,
    11571193                                            pstrSearch->psz,
     
    11991235                       PULONG pulOfs,               // in: where to begin search (0 = start);
    12001236                                                    // out: ofs of first char after replacement string
    1201                        const char *pcszSearch,      // in: search string; cannot be NULL
    1202                        const char *pcszReplace)     // in: replacement string; cannot be NULL
     1237                       PCSZ pcszSearch,      // in: search string; cannot be NULL
     1238                       PCSZ pcszReplace)     // in: replacement string; cannot be NULL
    12031239{
    12041240    XSTRING xstrFind,
     
    12921328
    12931329ULONG xstrEncode(PXSTRING pxstr,            // in/out: string to convert
    1294                  const char *pcszEncode)    // in: characters to encode (e.g. "%,();=")
     1330                 PCSZ pcszEncode)    // in: characters to encode (e.g. "%,();=")
    12951331{
    12961332    ULONG ulrc = 0,
Note: See TracChangeset for help on using the changeset viewer.