Changeset 1863 for trunk/src/kmk/make.h
- Timestamp:
- Oct 14, 2008, 11:46:23 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/make.h
r1857 r1863 496 496 497 497 char *strip_whitespace (const char **begpp, const char **endpp); 498 499 #ifdef CONFIG_WITH_ALLOC_CACHES 500 /* alloccache (misc.c) */ 501 502 struct alloccache_free_ent 503 { 504 struct alloccache_free_ent *next; 505 }; 506 507 struct alloccache 508 { 509 char *free_start; 510 char *free_end; 511 struct alloccache_free_ent *free_head; 512 unsigned int size; 513 unsigned int alloc_count; 514 unsigned int total_count; 515 const char *name; 516 struct alloccache *next; 517 void *grow_arg; 518 void *(*grow_alloc)(void *grow_arg, unsigned int size); 519 }; 520 521 void alloccache_init (struct alloccache *cache, unsigned int size, const char *name, 522 void *(*grow_alloc)(void *grow_arg, unsigned int size), void *grow_arg); 523 void alloccache_join (struct alloccache *cache, struct alloccache *eat); 524 void alloccache_print (struct alloccache *cache); 525 void alloccache_print_all (void); 526 struct alloccache_free_ent *alloccache_alloc_grow (struct alloccache *cache); 527 528 /* Allocate an item. */ 529 MY_INLINE void * 530 alloccache_alloc (struct alloccache *cache) 531 { 532 struct alloccache_free_ent *f = cache->free_head; 533 if (f) 534 cache->free_head = f->next; 535 else if (cache->free_start != cache->free_end) 536 { 537 f = (struct alloccache_free_ent *)cache->free_start; 538 cache->free_start += cache->size; 539 } 540 else 541 f = alloccache_alloc_grow (cache); 542 cache->alloc_count++; 543 return f; 544 } 545 546 /* Allocate a cleared item. */ 547 MY_INLINE void * 548 alloccache_calloc (struct alloccache *cache) 549 { 550 void *item = alloccache_alloc (cache); 551 memset (item, '\0', cache->size); 552 return item; 553 } 554 555 /* Free an item. */ 556 MY_INLINE void 557 alloccache_free (struct alloccache *cache, void *item) 558 { 559 struct alloccache_free_ent *f = (struct alloccache_free_ent *)item; 560 #if 0 /*ndef NDEBUG*/ 561 struct alloccache_free_ent *c; 562 unsigned int i = 0; 563 for (c = cache->free_head; c != NULL; c = c->next, i++) 564 MY_ASSERT_MSG (c != f && i < 0x10000000, 565 ("i=%u total_count=%u\n", i, cache->total_count)); 566 #endif 567 568 f->next = cache->free_head; 569 cache->free_head = f; 570 cache->alloc_count--; 571 } 572 573 /* the alloc caches */ 574 extern struct alloccache dep_cache; 575 extern struct alloccache nameseq_cache; 576 extern struct alloccache variable_cache; 577 578 #endif /* CONFIG_WITH_ALLOC_CACHES */ 579 498 580 499 581 /* String caching */
Note:
See TracChangeset
for help on using the changeset viewer.