Mercurial > hg > xemacs-beta
comparison src/gmalloc.c @ 2312:ed6535aefb7e
[xemacs-hg @ 2004-09-27 18:51:20 by james]
Fix gcc 3.3 'log' shadow warning by changing to 'log2'.
author | james |
---|---|
date | Mon, 27 Sep 2004 18:51:22 +0000 |
parents | e22b0213b713 |
children | aa5ed11f473b |
comparison
equal
deleted
inserted
replaced
2311:2200ebac5409 | 2312:ed6535aefb7e |
---|---|
572 /* Determine the allocation policy based on the request size. */ | 572 /* Determine the allocation policy based on the request size. */ |
573 if (size <= BLOCKSIZE / 2) | 573 if (size <= BLOCKSIZE / 2) |
574 { | 574 { |
575 /* Small allocation to receive a fragment of a block. | 575 /* Small allocation to receive a fragment of a block. |
576 Determine the logarithm to base two of the fragment size. */ | 576 Determine the logarithm to base two of the fragment size. */ |
577 __malloc_size_t log = 1; | 577 __malloc_size_t log2 = 1; |
578 --size; | 578 --size; |
579 while ((size /= 2) != 0) | 579 while ((size /= 2) != 0) |
580 ++log; | 580 ++log2; |
581 | 581 |
582 /* Look in the fragment lists for a | 582 /* Look in the fragment lists for a |
583 free fragment of the desired size. */ | 583 free fragment of the desired size. */ |
584 next = _fraghead[log].next; | 584 next = _fraghead[log2].next; |
585 if (next != NULL) | 585 if (next != NULL) |
586 { | 586 { |
587 /* There are free fragments of this size. | 587 /* There are free fragments of this size. |
588 Pop a fragment out of the fragment list and return it. | 588 Pop a fragment out of the fragment list and return it. |
589 Update the block's nfree and first counters. */ | 589 Update the block's nfree and first counters. */ |
593 next->next->prev = next->prev; | 593 next->next->prev = next->prev; |
594 block = BLOCK (result); | 594 block = BLOCK (result); |
595 if (--_heapinfo[block].busy.info.frag.nfree != 0) | 595 if (--_heapinfo[block].busy.info.frag.nfree != 0) |
596 _heapinfo[block].busy.info.frag.first = (unsigned long int) | 596 _heapinfo[block].busy.info.frag.first = (unsigned long int) |
597 ((unsigned long int) ((char *) next->next - (char *) NULL) | 597 ((unsigned long int) ((char *) next->next - (char *) NULL) |
598 % BLOCKSIZE) >> log; | 598 % BLOCKSIZE) >> log2; |
599 | 599 |
600 /* Update the statistics. */ | 600 /* Update the statistics. */ |
601 ++_chunks_used; | 601 ++_chunks_used; |
602 _bytes_used += 1 << log; | 602 _bytes_used += 1 << log2; |
603 --_chunks_free; | 603 --_chunks_free; |
604 _bytes_free -= 1 << log; | 604 _bytes_free -= 1 << log2; |
605 } | 605 } |
606 else | 606 else |
607 { | 607 { |
608 /* No free fragments of the desired size, so get a new block | 608 /* No free fragments of the desired size, so get a new block |
609 and break it into fragments, returning the first. */ | 609 and break it into fragments, returning the first. */ |
610 result = malloc (BLOCKSIZE); | 610 result = malloc (BLOCKSIZE); |
611 if (result == NULL) | 611 if (result == NULL) |
612 return NULL; | 612 return NULL; |
613 | 613 |
614 /* Link all fragments but the first into the free list. */ | 614 /* Link all fragments but the first into the free list. */ |
615 for (i = 1; i < (__malloc_size_t) (BLOCKSIZE >> log); ++i) | 615 for (i = 1; i < (__malloc_size_t) (BLOCKSIZE >> log2); ++i) |
616 { | 616 { |
617 next = (struct list *) ((char *) result + (i << log)); | 617 next = (struct list *) ((char *) result + (i << log2)); |
618 next->next = _fraghead[log].next; | 618 next->next = _fraghead[log2].next; |
619 next->prev = &_fraghead[log]; | 619 next->prev = &_fraghead[log2]; |
620 next->prev->next = next; | 620 next->prev->next = next; |
621 if (next->next != NULL) | 621 if (next->next != NULL) |
622 next->next->prev = next; | 622 next->next->prev = next; |
623 } | 623 } |
624 | 624 |
625 /* Initialize the nfree and first counters for this block. */ | 625 /* Initialize the nfree and first counters for this block. */ |
626 block = BLOCK (result); | 626 block = BLOCK (result); |
627 _heapinfo[block].busy.type = log; | 627 _heapinfo[block].busy.type = log2; |
628 _heapinfo[block].busy.info.frag.nfree = i - 1; | 628 _heapinfo[block].busy.info.frag.nfree = i - 1; |
629 _heapinfo[block].busy.info.frag.first = i - 1; | 629 _heapinfo[block].busy.info.frag.first = i - 1; |
630 | 630 |
631 _chunks_free += (BLOCKSIZE >> log) - 1; | 631 _chunks_free += (BLOCKSIZE >> log2) - 1; |
632 _bytes_free += BLOCKSIZE - (1 << log); | 632 _bytes_free += BLOCKSIZE - (1 << log2); |
633 _bytes_used -= BLOCKSIZE - (1 << log); | 633 _bytes_used -= BLOCKSIZE - (1 << log2); |
634 } | 634 } |
635 } | 635 } |
636 else | 636 else |
637 { | 637 { |
638 /* Large allocation to receive one or more blocks. | 638 /* Large allocation to receive one or more blocks. |