Changeset 1878 in kBuild for trunk/src/kmk/dir.c
- Timestamp:
- Oct 17, 2008 1:46:59 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/dir.c
r1794 r1878 345 345 static struct hash_table directory_contents; 346 346 347 #ifdef CONFIG_WITH_ALLOC_CACHES 348 /* Allocation cache for directory contents. */ 349 struct alloccache directory_contents_cache; 350 #endif 351 347 352 struct directory 348 353 { … … 376 381 /* Table of directories hashed by name. */ 377 382 static struct hash_table directories; 383 384 #ifdef CONFIG_WITH_ALLOC_CACHES 385 /* Allocation cache for directories. */ 386 struct alloccache directories_cache; 387 #endif 378 388 379 389 /* Never have more than this many directories open at once. */ … … 420 430 #endif 421 431 432 #ifdef CONFIG_WITH_ALLOC_CACHES 433 /* Allocation cache for dirfiles. */ 434 struct alloccache dirfile_cache; 435 #endif 436 437 422 438 423 439 static int dir_contents_file_exists_p (struct directory_contents *dir, … … 461 477 462 478 p = name + strlen (name); 479 #ifndef CONFIG_WITH_ALLOC_CACHES 463 480 dir = xmalloc (sizeof (struct directory)); 481 #else 482 dir = alloccache_alloc (&directories_cache); 483 #endif 464 484 dir->name = strcache_add_len (name, p - name); 465 485 hash_insert_at (&directories, dir, dir_slot); … … 521 541 /* Nope; this really is a directory we haven't seen before. */ 522 542 543 #ifndef CONFIG_WITH_ALLOC_CACHES 523 544 dc = (struct directory_contents *) 524 545 xmalloc (sizeof (struct directory_contents)); 546 #else 547 dc = (struct directory_contents *) 548 alloccache_alloc (&directory_contents_cache); 549 #endif 525 550 526 551 /* Enter it in the contents hash table. */ … … 744 769 #endif 745 770 { 771 #ifndef CONFIG_WITH_ALLOC_CACHES 746 772 df = xmalloc (sizeof (struct dirfile)); 773 #else 774 df = alloccache_alloc (&dirfile_cache); 775 #endif 747 776 df->name = strcache_add_len (d->d_name, len); 748 777 df->length = len; … … 907 936 /* The directory could not be stat'd. We allocate a contents 908 937 structure for it, but leave it out of the contents hash table. */ 938 #ifndef CONFIG_WITH_ALLOC_CACHES 909 939 dir->contents = xmalloc (sizeof (struct directory_contents)); 940 #else 941 dir->contents = alloccache_alloc (&directory_contents_cache); 942 #endif 910 943 memset (dir->contents, '\0', sizeof (struct directory_contents)); 944 911 945 } 912 946 … … 919 953 /* Make a new entry and put it in the table. */ 920 954 955 #ifndef CONFIG_WITH_ALLOC_CACHES 921 956 new = xmalloc (sizeof (struct dirfile)); 957 #else 958 new = alloccache_alloc (&dirfile_cache); 959 #endif 922 960 new->length = strlen (filename); 923 961 new->name = strcache_add_len (filename, new->length); … … 1279 1317 directory_contents_hash_1, directory_contents_hash_2, 1280 1318 directory_contents_hash_cmp); 1281 } 1319 #ifdef CONFIG_WITH_ALLOC_CACHES 1320 alloccache_init (&directories_cache, sizeof (struct directory), 1321 "directories", NULL, NULL); 1322 alloccache_init (&directory_contents_cache, sizeof (struct directory_contents), 1323 "directory_contents", NULL, NULL); 1324 alloccache_init (&dirfile_cache, sizeof (struct dirfile), 1325 "dirfile", NULL, NULL); 1326 #endif 1327 }
Note:
See TracChangeset
for help on using the changeset viewer.