Changeset 3167 for trunk/src/lib
- Timestamp:
- Mar 20, 2018, 10:47:25 PM (7 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/kDep.c
r3140 r3167 73 73 74 74 75 /******************************************************************************* 76 * Global Variables * 77 *******************************************************************************/ 78 /** List of dependencies. */ 79 static PDEP g_pDeps = NULL; 75 /** 76 * Initializes the dep instance. 77 * 78 * @param pThis The dep instance to init. 79 */ 80 void depInit(PDEPGLOBALS pThis) 81 { 82 pThis->pDeps = NULL; 83 } 84 85 86 /** 87 * Cleans up the dep instance (frees resources). 88 * 89 * @param pThis The dep instance to cleanup. 90 */ 91 void depCleanup(PDEPGLOBALS pThis) 92 { 93 PDEP pDep = pThis->pDeps; 94 pThis->pDeps = NULL; 95 while (pDep) 96 { 97 PDEP pFree = pDep; 98 pDep = pDep->pNext; 99 free(pFree); 100 } 101 } 80 102 81 103 … … 196 218 * 'Optimizes' and corrects the dependencies. 197 219 */ 198 void depOptimize( int fFixCase, int fQuiet, const char *pszIgnoredExt)220 void depOptimize(PDEPGLOBALS pThis, int fFixCase, int fQuiet, const char *pszIgnoredExt) 199 221 { 200 222 /* … … 202 224 */ 203 225 size_t cchIgnoredExt = pszIgnoredExt ? strlen(pszIgnoredExt) : 0; 204 PDEP pDepOrg = g_pDeps;205 PDEP pDep = g_pDeps;206 g_pDeps = NULL;226 PDEP pDepOrg = pThis->pDeps; 227 PDEP pDep = pThis->pDeps; 228 pThis->pDeps = NULL; 207 229 for (; pDep; pDep = pDep->pNext) 208 230 { … … 287 309 * Insert the corrected dependency. 288 310 */ 289 depAdd(p szFilename, strlen(pszFilename));311 depAdd(pThis, pszFilename, strlen(pszFilename)); 290 312 } 291 313 … … 305 327 * Prints the dependency chain. 306 328 * 307 * @ returns Pointer to the allocated dependency.329 * @param pThis The 'dep' instance. 308 330 * @param pOutput Output stream. 309 331 */ 310 void depPrint( FILE *pOutput)332 void depPrint(PDEPGLOBALS pThis, FILE *pOutput) 311 333 { 312 334 PDEP pDep; 313 for (pDep = g_pDeps; pDep; pDep = pDep->pNext)335 for (pDep = pThis->pDeps; pDep; pDep = pDep->pNext) 314 336 fprintf(pOutput, " \\\n\t%s", pDep->szFilename); 315 337 fprintf(pOutput, "\n\n"); … … 319 341 /** 320 342 * Prints empty dependency stubs for all dependencies. 321 */ 322 void depPrintStubs(FILE *pOutput) 343 * 344 * @param pThis The 'dep' instance. 345 * @param pOutput Output stream. 346 */ 347 void depPrintStubs(PDEPGLOBALS pThis, FILE *pOutput) 323 348 { 324 349 PDEP pDep; 325 for (pDep = g_pDeps; pDep; pDep = pDep->pNext)350 for (pDep = pThis->pDeps; pDep; pDep = pDep->pNext) 326 351 fprintf(pOutput, "%s:\n\n", pDep->szFilename); 327 352 } … … 355 380 * 356 381 * @returns Pointer to the allocated dependency. 382 * @param pThis The 'dep' instance. 357 383 * @param pszFilename The filename. Does not need to be terminated. 358 384 * @param cchFilename The length of the filename. 359 385 */ 360 PDEP depAdd( const char *pszFilename, size_t cchFilename)386 PDEP depAdd(PDEPGLOBALS pThis, const char *pszFilename, size_t cchFilename) 361 387 { 362 388 unsigned uHash = sdbm(pszFilename, cchFilename); … … 368 394 */ 369 395 pDepPrev = NULL; 370 for (pDep = g_pDeps; pDep; pDepPrev = pDep, pDep = pDep->pNext)396 for (pDep = pThis->pDeps; pDep; pDepPrev = pDep, pDep = pDep->pNext) 371 397 if ( pDep->uHash == uHash 372 398 && pDep->cchFilename == cchFilename … … 397 423 else 398 424 { 399 pDep->pNext = g_pDeps;400 g_pDeps = pDep;425 pDep->pNext = pThis->pDeps; 426 pThis->pDeps = pDep; 401 427 } 402 428 return pDep; 403 }404 405 406 /**407 * Frees the current dependency chain.408 */409 void depCleanup(void)410 {411 PDEP pDep = g_pDeps;412 g_pDeps = NULL;413 while (pDep)414 {415 PDEP pFree = pDep;416 pDep = pDep->pNext;417 free(pFree);418 }419 429 } 420 430 -
trunk/src/lib/kDep.h
r2955 r3167 46 46 } DEP, *PDEP; 47 47 48 typedef struct DEPGLOBALS 49 { 50 /** List of dependencies. */ 51 PDEP pDeps; 48 52 49 extern PDEP depAdd(const char *pszFilename, size_t cchFilename); 50 extern void depOptimize(int fFixCase, int fQuiet, const char *pszIgnoredExt); 51 extern void depPrint(FILE *pOutput); 52 extern void depPrintStubs(FILE *pOutput); 53 extern void depCleanup(void); 53 } DEPGLOBALS; 54 typedef DEPGLOBALS *PDEPGLOBALS; 55 56 extern void depInit(PDEPGLOBALS pThis); 57 extern void depCleanup(PDEPGLOBALS pThis); 58 extern PDEP depAdd(PDEPGLOBALS pThis, const char *pszFilename, size_t cchFilename); 59 extern void depOptimize(PDEPGLOBALS pThis, int fFixCase, int fQuiet, const char *pszIgnoredExt); 60 extern void depPrint(PDEPGLOBALS pThis, FILE *pOutput); 61 extern void depPrintStubs(PDEPGLOBALS pThis, FILE *pOutput); 62 54 63 extern void *depReadFileIntoMemory(FILE *pInput, size_t *pcbFile, void **ppvOpaque); 55 64 extern void depFreeFileMemory(void *pvFile, void *pvOpaque);
Note:
See TracChangeset
for help on using the changeset viewer.