Ignore:
Timestamp:
Dec 12, 2002, 12:50:50 PM (23 years ago)
Author:
umoeller
Message:

Minor changes.

File:
1 edited

Legend:

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

    r222 r235  
    8383STATIC ULONG               G_cEntities = 0;
    8484
    85 /*
    86  *@@ ReplaceEntities:
     85STATIC HMTX        G_hmtxStringsCache = NULLHANDLE;
     86STATIC TREE        *G_StringsCache;
     87STATIC LONG        G_cStringsInCache = 0;
     88
     89
     90/*
     91 *@@ nlsReplaceEntities:
    8792 *
    8893 *@@added V0.9.16 (2001-09-29) [umoeller]
    8994 */
    9095
    91 STATIC ULONG ReplaceEntities(PXSTRING pstr)
     96ULONG nlsReplaceEntities(PXSTRING pstr)
    9297{
    9398    ULONG ul,
     
    107112    }
    108113
    109     return (rc);
    110 }
    111 
    112 /*
    113  *@@ LoadString:
    114  *
    115  *@@added V0.9.18 (2002-03-08) [umoeller]
    116  */
    117 
    118 STATIC void LoadString(ULONG ulID,
    119                        PSZ *ppsz,
    120                        PULONG pulLength)        // out: length of new string (ptr can be NULL)
     114    return rc;
     115}
     116
     117/*
     118 *@@ nlsLoadString:
     119 *
     120 *@@changed V0.9.0 [umoeller]: "string not found" is now re-allocated using strdup (avoids crashes)
     121 *@@changed V0.9.0 (99-11-28) [umoeller]: added more meaningful error message
     122 *@@changed V0.9.2 (2000-02-26) [umoeller]: made temporary buffer larger
     123 *@@changed V0.9.16 (2001-09-29) [umoeller]: added entities support
     124 *@@changed V0.9.16 (2002-01-26) [umoeller]: added pulLength param
     125 *@@changed V1.0.0 (2002-09-17) [umoeller]: optimized
     126 *@@changed V1.0.1 (2002-12-11) [umoeller]: moved this here from XWorkplace common.c
     127 */
     128
     129VOID nlsLoadString(ULONG ulID,
     130                   PSZ *ppsz,
     131                   PULONG pulLength)        // out: length of new string (ptr can be NULL)
    121132{
    122133    CHAR szBuf[500];
     
    138149
    139150    xstrInitCopy(&str, szBuf, 0);
    140     ReplaceEntities(&str);
     151    nlsReplaceEntities(&str);
    141152    *ppsz = str.psz;
    142153    if (pulLength)
     
    144155    // do not free string
    145156}
    146 
    147 STATIC HMTX        G_hmtxStringsCache = NULLHANDLE;
    148 STATIC TREE        *G_StringsCache;
    149 STATIC LONG        G_cStringsInCache = 0;
    150157
    151158/*
     
    202209
    203210/*
     211 *@@ Unload:
     212 *      removes all loaded strings from memory.
     213 *
     214 *@@added V0.9.9 (2001-04-04) [umoeller]
     215 *@@changed V1.0.1 (2002-12-11) [umoeller]: moved this here from XWorkplace common.c
     216 */
     217
     218STATIC VOID Unload(VOID)
     219{
     220    // to delete all nodes, build a temporary
     221    // array of all string node pointers;
     222    // we don't want to rebalance the tree
     223    // for each node
     224    LONG            cNodes = G_cStringsInCache;
     225    PSTRINGTREENODE *papNodes
     226        = (PSTRINGTREENODE*)treeBuildArray(G_StringsCache,
     227                                           &cNodes);
     228    if (papNodes)
     229    {
     230        // delete all nodes in array
     231        ULONG ul;
     232        for (ul = 0;
     233             ul < cNodes;
     234             ul++)
     235        {
     236            free(papNodes[ul]);
     237        }
     238
     239        free(papNodes);
     240    }
     241
     242    // reset the tree to "empty"
     243    treeInit(&G_StringsCache,
     244             &G_cStringsInCache);
     245}
     246
     247/*
    204248 *@@ nlsInitStrings:
    205249 *      initializes the NLS strings cache. Call this
     
    214258                    ULONG cEntities)            // in: array item count of paEntities or 0
    215259{
    216     G_hab = hab;
    217     G_hmod = hmod;
    218     G_paEntities = paEntities;
    219     G_cEntities = cEntities;
     260    BOOL    fLocked = FALSE;
     261
     262    TRY_LOUD(excpt1)
     263    {
     264        if (fLocked = LockStrings())
     265        {
     266            if (G_cStringsInCache)
     267                // not first call:
     268                Unload();
     269
     270            G_hab = hab;
     271            G_hmod = hmod;
     272            G_paEntities = paEntities;
     273            G_cEntities = cEntities;
     274        }
     275    }
     276    CATCH(excpt1) {} END_CATCH();
     277
     278    if (fLocked)
     279        UnlockStrings();
    220280}
    221281
     
    275335 *@@changed V0.9.16 (2001-10-19) [umoeller]: fixed bad string count which was never set
    276336 *@@changed V0.9.16 (2002-01-26) [umoeller]: optimized heap locality
     337 *@@changed V1.0.1 (2002-12-11) [umoeller]: moved this here from XWorkplace common.c
    277338 */
    278339
     
    299360                ULONG   ulLength = 0;
    300361
    301                 LoadString(ulStringID,
    302                            &psz,
    303                            &ulLength);
     362                nlsLoadString(ulStringID,
     363                              &psz,
     364                              &ulLength);
    304365
    305366                if (    (!psz)
     
    336397        UnlockStrings();
    337398
    338     return (pszReturn);
    339 }
    340 
    341 
     399    return pszReturn;
     400}
     401
     402
Note: See TracChangeset for help on using the changeset viewer.