Changeset 21


Ignore:
Timestamp:
Jan 8, 2001, 6:54:48 PM (25 years ago)
Author:
umoeller
Message:

Final changes for 0.9.7, i hope...

Location:
trunk
Files:
36 edited

Legend:

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

    r17 r21  
    3939    #endif
    4040
     41    /*
     42     *@@category: Helpers\PM helpers\Container helpers\Details view helpers
     43     */
     44
    4145    /* ******************************************************************
    4246     *
     
    107111                                 ULONG ulFieldReturn);
    108112
     113    /*
     114     *@@category: Helpers\PM helpers\Container helpers\Record core helpers
     115     */
     116
    109117    /* ******************************************************************
    110118     *
     
    174182        WinSendMsg(hwndCnr, CM_INVALIDATERECORD, NULL, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION | CMA_TEXTCHANGED))
    175183
     184    /*
     185     *@@category: Helpers\PM helpers\Container helpers\View management
     186     */
     187
    176188    /* ******************************************************************
    177189     *
     
    186198     *      be a PCNRINFO.
    187199     *      Example:
     200     *
    188201     +          CNRINFO CnrInfo;
    189202     +          cnrhQueryCnrInfo(&CnrInfo);
     
    199212    /*
    200213     *@@ BEGIN_CNRINFO:
    201      *      this func starts a "container info" block for the
    202      *      following functions.
     214     *      this macro starts a "container info" block. In such
     215     *      a block, you may use the following macros:
     216     *
     217     *      -- cnrhSetTitle
     218     *
     219     *      -- cnrhSetSplitBarAfter
     220     *
     221     *      -- cnrhSetSplitBarPos
     222     *
     223     *      -- cnrhSetTreeBmpOrIconSize
     224     *
     225     *      -- cnrhSetBmpOrIconSize
     226     *
     227     *      -- cnrhSetView (most frequently)
     228     *
     229     *      -- cnrhSetTreeIndent
     230     *
     231     *      -- cnrhSetSortFunc
     232     *
     233     *      Typical usage is like this:
     234     *
     235     +          BEGIN_CNRINFO()
     236     +          {
     237     +              cnrhSetTreeIndent(20);
     238     +              cnrhSetView(CV_TREE | CV_ICON | CA_TREELINE);
     239     +          } END_CNRINFO(hwndCnr);
     240     *
    203241     *      This must always be followed by END_CNRINFO(),
    204242     *      or you'll get funny compilation errors.
     
    215253    /*
    216254     *@@ END_CNRINFO:
    217      *      this ends a "container info" block started by
    218      *      BEGIN_CNRINFO.
     255     *      this macro ends a "container info" block.
     256     *      See BEGIN_CNRINFO.
    219257     *
    220258     *@@added V0.9.0
     
    228266    /*
    229267     *@@ cnrhSetTitle:
    230      *      this sets the container title to the specified
     268     *      this macro sets the container title to the specified
    231269     *      text. You must specify CA_CONTAINERTITLE with
    232270     *      cnrhSetView then.
     271     *
     272     *      This can only be used after BEGIN_CNRINFO().
    233273     *
    234274     *@@added V0.9.1 (99-12-18) [umoeller]
     
    278318     *      tree views.
    279319     *      The default is the system icon size (32 or 40).
     320     *
     321     *      This can only be used after BEGIN_CNRINFO().
    280322     */
    281323
     
    304346    /*
    305347     *@@ cnrhSetView:
    306      *      this sets the container view attributes (CNRINFO.flWindowAttr).
    307      *
    308      *      This can only be used after BEGIN_CNRINFO().
     348     *      this macro sets the container view attributes (CNRINFO.flWindowAttr).
     349     *
     350     *      This can only be used after BEGIN_CNRINFO(), like this:
     351     *
     352     +          BEGIN_CNRINFO()
     353     +          {
     354     +              cnrhSetView(CV_TEXT | CV_FLOW);
     355     +          } END_CNRINFO(hwndCnr);
    309356     *
    310357     *      The following combinations are useful for flWindowAttr.
     
    382429    /*
    383430     *@@ cnrhSetTreeIndent:
    384      *      this sets the horizontal spacing between levels
     431     *      this macro sets the horizontal spacing between levels
    385432     *      in Tree views.
     433     *
     434     *      This can only be used after BEGIN_CNRINFO().
    386435     *
    387436     *@@added V0.9.0
     
    394443    /*
    395444     *@@ cnrhSetSortFunc:
    396      *      this sets the sort function for a container.
     445     *      this macro sets the sort function for a container.
     446     *
    397447     *      This can only be used after BEGIN_CNRINFO().
    398448     *
     
    473523                                            PRECORDCORE preccCurrent);
    474524
     525    /*
     526     *@@category: Helpers\PM helpers\Container helpers\Record relations/iteration
     527     */
     528
    475529    /* ******************************************************************
    476530     *
  • trunk/include/helpers/comctl.h

    r20 r21  
    440440    // TOOLINFO.uFlags flags (ORed)
    441441    // #define TTF_IDISHWND            0x0001
    442                 // V0.9.7 (2001-01-03) [umoeller]: removed this win95 bullshit
     442                // V0.9.7 (2001-01-03) [umoeller]: removed this win95 crap
    443443    #define TTF_CENTERBELOW         0x0002
    444444    #define TTF_CENTERABOVE         0x0004
    445445    // #define TTF_RTLREADING          0x0004
    446                 // V0.9.7 (2001-01-03) [umoeller]: removed this win95 bullshit
     446                // V0.9.7 (2001-01-03) [umoeller]: removed this win95 crap
    447447    #define TTF_SUBCLASS            0x0008
    448448    // non-Win95 flags
     
    460460     *      and many other TTM_* messages.
    461461     *
    462      *@@changed V0.9.7 (2001-01-03) [umoeller]: removed all that win95 bullshit
     462     *@@changed V0.9.7 (2001-01-03) [umoeller]: removed all that win95 crap
    463463     */
    464464
     
    526526     *      This structure is used with the TTN_NEEDTEXT notification.
    527527     *
    528      *@@changed V0.9.7 (2001-01-03) [umoeller]: got rid of this win95 bullshit
     528     *@@changed V0.9.7 (2001-01-03) [umoeller]: got rid of this win95 crap
    529529     */
    530530
  • trunk/include/helpers/stringh.h

    r14 r21  
    125125                     const char *pcszEndChars);
    126126
    127     PSZ strhFindEOL(PSZ pszSearchIn, ULONG *pulOffset);
     127    PSZ strhFindEOL(const char *pcszSearchIn, ULONG *pulOffset);
    128128
    129129    PSZ strhFindNextLine(PSZ pszSearchIn, PULONG pulOffset);
  • trunk/include/helpers/textv_html.h

    r14 r21  
    6666            PSZ         pszTitle;           // contents of TITLE tag (must be freed)
    6767            LINKLIST    llLinks;            // list of XHTMLLINK structures; empty if none
     68                                            // (auto-free mode; use lstClear)
    6869        } XHTMLDATA, *PXHTMLDATA;
    6970    #endif
  • trunk/include/helpers/xstring.h

    r18 r21  
    6565    typedef void XWPENTRY XSTRCLEAR(PXSTRING pxstr);
    6666    typedef XSTRCLEAR *PXSTRCLEAR;
     67
     68    ULONG XWPENTRY xstrReserve(PXSTRING pxstr, ULONG ulBytes);
     69    typedef ULONG XWPENTRY XSTRRESERVE(PXSTRING pxstr, ULONG ulBytes);
     70    typedef XSTRRESERVE *PXSTRRESERVE;
    6771
    6872    PXSTRING XWPENTRY xstrCreate(ULONG ulPreAllocate);
  • trunk/readme.txt

    r16 r21  
    1 XWP Helpers 0.9.6 README
     1XWP Helpers 0.9.7 README
    22(W) Ulrich M”ller, October 26, 2000
    3 Last updated December 11, 2000, Ulrich M”ller
     3Last updated January 6, 2001, Ulrich M”ller
    44
    55
     
    131131
    132132    Of course, nothing stops you from writing your own makefile
    133     if you find all this to complicated. However, if you choose
     133    if you find all this too complicated. However, if you choose
    134134    to use my makefile from within your own project, you can
    135135    then simply change to the src\helpers directory and start a
     
    159159    compile.
    160160
     161    I have a "flat" include policy, meaning that include files
     162    may not include other files. Instead, #include's may only
     163    occur in C files. This makes makefile dependencies easier
     164    to maintain.
     165
    161166    Besides, the helpers C code expects a file called "setup.h"
    162167    in your include path somewhere. This is included by _all_
     
    178183            // with VAC, use _Optlink; that's faster than _System
    179184            #define XWPENTRY _Optlink
     185            // or: #define XWPENTRY _System
    180186        #endif
    181187
  • trunk/src/helpers/animate.c

    r18 r21  
    6565/*
    6666 *@@category: Helpers\PM helpers\Animation helpers
     67 *      See animate.c.
    6768 */
    6869
  • trunk/src/helpers/cctl_chart.c

    r18 r21  
    8181/*
    8282 *@@category: Helpers\PM helpers\Window classes\Chart control
     83 *      See cctl_chart.c.
    8384 */
    8485
  • trunk/src/helpers/cctl_checkcnr.c

    r14 r21  
    8181/*
    8282 *@@category: Helpers\PM helpers\Window classes\Checkbox containers
     83 *      See cctl_checkcnr.c.
    8384 */
    8485
  • trunk/src/helpers/cctl_progbar.c

    r18 r21  
    8181/*
    8282 *@@category: Helpers\PM helpers\Window classes\Progress bars
     83 *      See cctl_progbar.c.
    8384 */
    8485
  • trunk/src/helpers/cctl_splitwin.c

    r14 r21  
    8181/*
    8282 *@@category: Helpers\PM helpers\Window classes\Split windows
     83 *      See cctl_splitwin.c.
    8384 */
    8485
  • trunk/src/helpers/cctl_tooltip.c

    r20 r21  
    8181/*
    8282 *@@category: Helpers\PM helpers\Window classes\Tooltips
     83 *      See cctl_tooltip.c.
    8384 */
    8485
     
    12891290                    // compose values for that msg
    12901291                    TOOLTIPTEXT ttt = {0};
    1291                     _Pmpf(("TTM_GETTEXT: PSZ_TEXTCALLBACK"));
     1292                    _Pmpf(("TTM_GETTEXT: PSZ_TEXTCALLBACK... sending TTN_NEEDTEXT"));
    12921293                    ttt.hwndTooltip = hwndTooltip;
    12931294                    ttt.hwndTool = pti->hwndTool;
    1294                     WinSendMsg(pti->hwndTool,
     1295                    WinSendMsg(pti->hwndToolOwner,
    12951296                               WM_CONTROL,
    12961297                               MPFROM2SHORT(pttd->ulTooltipID,  // tooltip control wnd ID
  • trunk/src/helpers/cnrh.c

    r17 r21  
    6363
    6464/*
     65 *@@category: Helpers\PM helpers\Container helpers
     66 *      See cnrh.c.
     67 */
     68
     69/*
    6570 *@@category: Helpers\PM helpers\Container helpers\Details view helpers
     71 *      these functions aid you in setting up the FIELDINFO structures
     72 *      for a container Details view. Use cnrhSetFieldInfos for that.
    6673 */
    6774
     
    343350/*
    344351 *@@category: Helpers\PM helpers\Container helpers\Record core helpers
     352 *      functions for allocating and inserting records more easily.
     353 *
     354 *      Use cnrhAllocRecords first to allocate, then cnrhInsertRecords
     355 *      to insert the records.
    345356 */
    346357
     
    742753/*
    743754 *@@category: Helpers\PM helpers\Container helpers\View management
     755 *      functions for easily managing container views.
     756 *
     757 *      Most importantly, this has the BEGIN_CNRINFO and END_CNRINFO
     758 *      macros which make CNRINFO handling easier. Also see
     759 *      cnrhSetView for that.
    744760 */
    745761
     
    812828 *
    813829 *      With fl, specify any or none of the following:
     830 *
    814831 *      --  FRFP_RIGHTSPLITWINDOW: test right split Details view
    815832 *              instead of main cnr.
     833 *
    816834 *      --  FRFP_SCREENCOORDS: *pptl specifies the point to
    817835 *              check in _screen_ coordinates, instead of
     
    13101328/*
    13111329 *@@category: Helpers\PM helpers\Container helpers\Record relations/iteration
     1330 *      functions for querying the relation of records and
     1331 *      iterating through records.
    13121332 */
    13131333
     
    13961416            // first call: get parent of precTest;
    13971417            // subsequent calls: climb up
    1398             precParentThis = WinSendMsg(hwndCnr,
    1399                                         CM_QUERYRECORD,
    1400                                         precParentThis,
    1401                                         MPFROM2SHORT(CMA_PARENT,
    1402                                                      CMA_ITEMORDER));
     1418            precParentThis = (PRECORDCORE)WinSendMsg(hwndCnr,
     1419                                                     CM_QUERYRECORD,
     1420                                                     precParentThis,
     1421                                                     MPFROM2SHORT(CMA_PARENT,
     1422                                                                  CMA_ITEMORDER));
    14031423            if (precParentThis == (PRECORDCORE)-1)
    14041424                break;
  • trunk/src/helpers/comctl.c

    r14 r21  
    124124/*
    125125 *@@category: Helpers\PM helpers\Window classes\Menu buttons
     126 *      See comctl.c and ctlMakeMenuButton.
    126127 */
    127128
     
    495496/*
    496497 *@@category: Helpers\PM helpers\Window classes\Static bitmaps
     498 *      See comctl.c and ctl_fnwpBitmapStatic.
    497499 */
    498500
     
    978980/*
    979981 *@@category: Helpers\PM helpers\Window classes\Stretched bitmaps
     982 *      See comctl.c and ctlPrepareStretchedBitmap.
    980983 */
    981984
     
    10611064/*
    10621065 *@@category: Helpers\PM helpers\Window classes\Hotkey entry field
     1066 *      See comctl.c and ctl_fnwpObjectHotkeyEntryField.
    10631067 */
    10641068
  • trunk/src/helpers/datetime.c

    r15 r21  
    5454/*
    5555 *@@category: Helpers\C helpers\Date/time helpers
     56 *      See datetime.c.
    5657 */
    5758
  • trunk/src/helpers/debug.c

    r14 r21  
    8888/*
    8989 *@@category: Helpers\Control program helpers\Exceptions/debugging
     90 *      See except.c and debug.c.
    9091 */
    9192
  • trunk/src/helpers/dosh.c

    r17 r21  
    7373/*
    7474 *@@category: Helpers\Control program helpers\Miscellaneous
     75 *      Miscellaneous helpers in dosh.c that didn't fit into any other
     76 *      category.
    7577 */
    7678
     
    215217
    216218/*
    217  *@@category: Helpers\Control program helpers\Memory management
     219 *@@category: Helpers\Control program helpers\Shared memory management
     220 *      helpers for allocating and requesting shared memory.
    218221 */
    219222
     
    286289/*
    287290 *@@category: Helpers\Control program helpers\Drive management
     291 *      functions for managing drives... enumerating, testing,
     292 *      querying etc.
    288293 */
    289294
     
    12971302/*
    12981303 *@@category: Helpers\Control program helpers\Directory management
     1304 *      directory helpers (querying, creating, deleting etc.).
    12991305 */
    13001306
     
    15341540/*
    15351541 *@@category: Helpers\Control program helpers\Module handling
     1542 *      helpers for importing functions from a module (DLL).
    15361543 */
    15371544
     
    15911598/*
    15921599 *@@category: Helpers\Control program helpers\Performance (CPU load) helpers
     1600 *      helpers around DosPerfSysCall.
    15931601 */
    15941602
     
    18521860/*
    18531861 *@@category: Helpers\Control program helpers\Process management
     1862 *      helpers for starting subprocesses.
    18541863 */
    18551864
  • trunk/src/helpers/dosh2.c

    r18 r21  
    346346/*
    347347 *@@category: Helpers\Control program helpers\Environment management
     348 *      helpers for managing those ugly environment string arrays
     349 *      that are used with DosStartSession and WinStartApp.
    348350 */
    349351
     
    749751/*
    750752 *@@category: Helpers\Control program helpers\Executable info
     753 *      these functions can retrieve BLDLEVEL information from
     754 *      any executable module. See doshExecOpen.
    751755 */
    752756
     
    11951199/*
    11961200 *@@category: Helpers\Control program helpers\Partitions info
     1201 *      functions for retrieving partition information directly
     1202 *      from the partition tables on the disk. See doshGetPartitionsList.
    11971203 */
    11981204
  • trunk/src/helpers/eah.c

    r14 r21  
    9898/*
    9999 *@@category: Helpers\Control program helpers\Extended attributes
     100 *      See eah.c.
    100101 */
    101102
     
    404405/*
    405406 *@@category: Helpers\Control program helpers\Extended attributes\Translation helpers
     407 *      these functions are built on top of the regular EA helpers
     408 *      (see eah.c) to convert standard types to EAs.
    406409 */
    407410
  • trunk/src/helpers/except.c

    r15 r21  
    264264/*
    265265 *@@category: Helpers\Control program helpers\Exceptions/debugging
     266 *      See except.c.
    266267 */
    267268
  • trunk/src/helpers/gpih.c

    r18 r21  
    7777LONG            DisplayCaps[CAPS_DEVICE_POLYSET_POINTS] = {0};
    7878BOOL            fCapsQueried = FALSE;
     79
     80/*
     81 *@@category: Helpers\PM helpers\GPI helpers
     82 *      See gpih.c.
     83 */
    7984
    8085/*
  • trunk/src/helpers/level.c

    r14 r21  
    5050/*
    5151 *@@category: Helpers\Control program helpers\SYSLEVEL parsing
     52 *      helpers for parsing SYSLEVEL files. See lvlOpenLevelFile.
    5253 */
    5354
  • trunk/src/helpers/linklist.c

    r17 r21  
    7979/*
    8080 *@@category: Helpers\C helpers\Linked lists
     81 *      See linklist.c.
    8182 */
    8283
  • trunk/src/helpers/memdebug.c

    r14 r21  
    131131/*
    132132 *@@category: Helpers\C helpers\Heap debugging
     133 *      See memdebug.c.
    133134 */
    134135
  • trunk/src/helpers/shapewin.c

    r14 r21  
    213213/*
    214214 *@@category: Helpers\PM helpers\Window classes\Shaped windows (transparency)
     215 *      see shapewin.c.
    215216 */
    216217
  • trunk/src/helpers/stringh.c

    r18 r21  
    5959/*
    6060 *@@category: Helpers\C helpers\String management
     61 *      See stringh.c and xstring.c.
     62 */
     63
     64/*
     65 *@@category: Helpers\C helpers\String management\C string helpers
     66 *      See stringh.c.
    6167 */
    6268
     
    988994 */
    989995
    990 PSZ strhFindEOL(PSZ pszSearchIn,        // in: where to search
     996PSZ strhFindEOL(const char *pcszSearchIn,        // in: where to search
    991997                PULONG pulOffset)       // out: offset (ptr can be NULL)
    992998{
    993     PSZ     p = pszSearchIn,
    994             prc = NULL;
     999    const char *p = pcszSearchIn,
     1000               *prc = 0;
    9951001    while (TRUE)
    9961002    {
     
    10041010
    10051011    if (pulOffset)
    1006         *pulOffset = prc - pszSearchIn;
    1007     return (prc);
     1012        *pulOffset = prc - pcszSearchIn;
     1013
     1014    return ((PSZ)prc);
    10081015}
    10091016
  • trunk/src/helpers/syssound.c

    r18 r21  
    9696/*
    9797 *@@category: Helpers\Profile (INI) helpers\System sounds
     98 *      see syssound.c.
    9899 */
    99100
  • trunk/src/helpers/textv_html.c

    r14 r21  
    5656/*
    5757 *@@category: Helpers\PM helpers\Window classes\XTextView control\HTML conversion
     58 *      see textv_html.c.
    5859 */
    5960
     
    20602061    ULONG   cbSource = strlen(*ppszText);
    20612062
     2063    XHTMLDATA xhtmlTemp = {0};
     2064    BOOL fUsingTemp = FALSE;
    20622065    COPYTARGET  ct = {0};
    20632066
     
    20692072    ct.fSkipNextSpace = TRUE;
    20702073    ct.pxhtml = (PXHTMLDATA)pxhtml;
     2074    if (ct.pxhtml == NULL)  // not specified:
     2075    {
     2076        ct.pxhtml = &xhtmlTemp;
     2077        fUsingTemp = TRUE;
     2078    }
     2079
     2080    lstInit(&ct.pxhtml->llLinks, TRUE);       // auto-free
    20712081
    20722082    // step 2:
     
    22182228    lstClear(&ct.llLists);
    22192229
     2230    if (fUsingTemp)
     2231    {
     2232        if (xhtmlTemp.pszTitle)
     2233            free(xhtmlTemp.pszTitle);
     2234        lstClear(&xhtmlTemp.llLinks);
     2235                // ### better really clear this... there are PSZ's inside
     2236    }
     2237
    22202238    return (brc);
    22212239}
  • trunk/src/helpers/threads.c

    r19 r21  
    66 *      message queue which is created automatically.
    77 *
     8 *      See thrCreate() for how to start such a thread.
     9 *
    810 *      Usage: All OS/2 programs.
    911 *
     
    1315 *      This file is new with V0.81 and contains all the thread
    1416 *      functions that used to be in helpers.c.
    15  *
    16  *      Use thrCreate() to start a thread.
    1717 *
    1818 *      Note: Version numbering in this file relates to XWorkplace version
     
    5656/*
    5757 *@@category: Helpers\Control program helpers\Thread management
     58 *      see threads.c.
    5859 */
    5960
  • trunk/src/helpers/timer.c

    r19 r21  
    9191/*
    9292 *@@category: Helpers\PM helpers\Timer replacements
     93 *      see timer.c.
    9394 */
    9495
  • trunk/src/helpers/tmsgfile.c

    r14 r21  
    8484/*
    8585 *@@category: Helpers\Control program helpers\Text message files (TMF)
     86 *      see tmsgfile.c.
    8687 */
    8788
  • trunk/src/helpers/tree.c

    r14 r21  
    102102/*
    103103 *@@category: Helpers\C helpers\Red-black balanced binary trees
     104 *      See tree.c.
    104105 */
    105106
  • trunk/src/helpers/winh.c

    r18 r21  
    24692469 *      wrapper around WinStartApp which fixes the
    24702470 *      specified PROGDETAILS to (hopefully) work
    2471  *      work with all executable types:
    2472  *
    2473  *      1.  This fixes the executable info to support:
    2474  *
    2475  *          -- starting "*" executables (command prompts
    2476  *             for OS/2, DOS, Win-OS/2);
    2477  *
    2478  *          -- starting ".CMD" and ".BAT" files as
    2479  *             PROGDETAILS.pszExecutable.
    2480  *
    2481  *      2.  Handles and merges special and default
    2482  *          environments for the app to be started.
    2483  *          If PROGDETAILS.pszEnvironment is empty
    2484  *          and the application is a Win-OS/2 app,
    2485  *          this uses the default Win-OS/2 settings
    2486  *          as specified in the "Win-OS/2" WPS settings
    2487  *          object.
     2471 *      work with all executable types.
     2472 *
     2473 *      This fixes the executable info to support:
     2474 *
     2475 *      -- starting "*" executables (command prompts
     2476 *         for OS/2, DOS, Win-OS/2);
     2477 *
     2478 *      -- starting ".CMD" and ".BAT" files as
     2479 *         PROGDETAILS.pszExecutable.
     2480 *
     2481 *      This also handles and merges special and default
     2482 *      environments for the app to be started.
     2483 *      If PROGDETAILS.pszEnvironment is empty
     2484 *      and the application is a Win-OS/2 app,
     2485 *      this uses the default Win-OS/2 settings
     2486 *      as specified in the "Win-OS/2" WPS settings
     2487 *      object.
    24882488 *
    24892489 *      Even though this isn't clearly said in PMREF,
  • trunk/src/helpers/wphandle.c

    r14 r21  
    6969/*
    7070 *@@category: Helpers\PM helpers\Workplace Shell\Handles (OS2SYS.INI)
     71 *      See wphandle.c.
    7172 */
    7273
  • trunk/src/helpers/xprf.c

    r14 r21  
    109109/*
    110110 *@@category: Helpers\Profile (INI) replacement functions
     111 *      See xprf.c.
    111112 */
    112113
  • trunk/src/helpers/xstring.c

    r18 r21  
    113113
    114114/*
    115  *@@category: Helpers\C helpers\String management
     115 *@@category: Helpers\C helpers\String management\XStrings (with memory management)
     116 *      See xstring.c.
    116117 */
    117118
     
    240241        free(pxstr->psz);
    241242    memset(pxstr, 0, sizeof(XSTRING));
     243}
     244
     245/*
     246 *@@ xstrReserve:
     247 *      this function makes sure that the specified
     248 *      XSTRING has at least ulBytes bytes allocated.
     249 *
     250 *      This function is useful if you plan to do
     251 *      a lot of string replacements or appends and
     252 *      want to avoid that the buffer is reallocated
     253 *      with each operation. Before those operations,
     254 *      call this function to make room for the operations.
     255 *
     256 *      If ulBytes is smaller than the current allocation,
     257 *      this function does nothing.
     258 *
     259 *      The XSTRING must be initialized before the
     260 *      call.
     261 *
     262 *      Returns the new total no. of allocated bytes.
     263 *
     264 *@@added V0.9.7 (2001-01-07) [umoeller]
     265 */
     266
     267ULONG xstrReserve(PXSTRING pxstr,
     268                  ULONG ulBytes)
     269{
     270    ULONG   cbNeeded = ulBytes;
     271
     272    if (cbNeeded > pxstr->cbAllocated)
     273    {
     274        // we need more memory than we have previously
     275        // allocated:
     276        if (pxstr->cbAllocated)
     277            // appendee already had memory:
     278            // reallocate
     279            pxstr->psz = (PSZ)realloc(pxstr->psz,
     280                                      cbNeeded);
     281        else
     282        {
     283            // appendee has no memory:
     284            pxstr->psz = (PSZ)malloc(cbNeeded);
     285            *(pxstr->psz) = 0;
     286        }
     287
     288        pxstr->cbAllocated = cbNeeded;
     289                // ulLength is unchanged
     290    }
     291
     292    return (pxstr->cbAllocated);
    242293}
    243294
Note: See TracChangeset for help on using the changeset viewer.