Changeset 235 for trunk/src/helpers/nlscache.c
- Timestamp:
- Dec 12, 2002, 12:50:50 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/helpers/nlscache.c
r222 r235 83 83 STATIC ULONG G_cEntities = 0; 84 84 85 /* 86 *@@ ReplaceEntities: 85 STATIC HMTX G_hmtxStringsCache = NULLHANDLE; 86 STATIC TREE *G_StringsCache; 87 STATIC LONG G_cStringsInCache = 0; 88 89 90 /* 91 *@@ nlsReplaceEntities: 87 92 * 88 93 *@@added V0.9.16 (2001-09-29) [umoeller] 89 94 */ 90 95 91 STATIC ULONGReplaceEntities(PXSTRING pstr)96 ULONG nlsReplaceEntities(PXSTRING pstr) 92 97 { 93 98 ULONG ul, … … 107 112 } 108 113 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 129 VOID nlsLoadString(ULONG ulID, 130 PSZ *ppsz, 131 PULONG pulLength) // out: length of new string (ptr can be NULL) 121 132 { 122 133 CHAR szBuf[500]; … … 138 149 139 150 xstrInitCopy(&str, szBuf, 0); 140 ReplaceEntities(&str);151 nlsReplaceEntities(&str); 141 152 *ppsz = str.psz; 142 153 if (pulLength) … … 144 155 // do not free string 145 156 } 146 147 STATIC HMTX G_hmtxStringsCache = NULLHANDLE;148 STATIC TREE *G_StringsCache;149 STATIC LONG G_cStringsInCache = 0;150 157 151 158 /* … … 202 209 203 210 /* 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 218 STATIC 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 /* 204 248 *@@ nlsInitStrings: 205 249 * initializes the NLS strings cache. Call this … … 214 258 ULONG cEntities) // in: array item count of paEntities or 0 215 259 { 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(); 220 280 } 221 281 … … 275 335 *@@changed V0.9.16 (2001-10-19) [umoeller]: fixed bad string count which was never set 276 336 *@@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 277 338 */ 278 339 … … 299 360 ULONG ulLength = 0; 300 361 301 LoadString(ulStringID,302 &psz,303 &ulLength);362 nlsLoadString(ulStringID, 363 &psz, 364 &ulLength); 304 365 305 366 if ( (!psz) … … 336 397 UnlockStrings(); 337 398 338 return (pszReturn);339 } 340 341 399 return pszReturn; 400 } 401 402
Note:
See TracChangeset
for help on using the changeset viewer.