diff options
| author | Paul Eggert | 2012-04-15 18:18:13 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-04-15 18:18:13 -0700 |
| commit | 3539f31f03b40bafa0875de88e3a5d55558ba32c (patch) | |
| tree | 2ee0306fd2a493abe8b0ac1234e3a3e94fa41519 /src/ralloc.c | |
| parent | a041960a7ca40a5af684efb3e859edd9daae907d (diff) | |
| download | emacs-3539f31f03b40bafa0875de88e3a5d55558ba32c.tar.gz emacs-3539f31f03b40bafa0875de88e3a5d55558ba32c.zip | |
Fix minor ralloc.c problems found by static checking.
See http://lists.gnu.org/archive/html/emacs-devel/2011-12/msg00720.html
* ralloc.c (ALIGNED, ROUND_TO_PAGE, HEAP_PTR_SIZE)
(r_alloc_size_in_use, r_alloc_freeze, r_alloc_thaw): Remove; unused.
(r_alloc_sbrk): Now static.
Diffstat (limited to 'src/ralloc.c')
| -rw-r--r-- | src/ralloc.c | 60 |
1 files changed, 1 insertions, 59 deletions
diff --git a/src/ralloc.c b/src/ralloc.c index 896ad9f3155..4bb2f240438 100644 --- a/src/ralloc.c +++ b/src/ralloc.c | |||
| @@ -95,10 +95,8 @@ static int extra_bytes; | |||
| 95 | /* Macros for rounding. Note that rounding to any value is possible | 95 | /* Macros for rounding. Note that rounding to any value is possible |
| 96 | by changing the definition of PAGE. */ | 96 | by changing the definition of PAGE. */ |
| 97 | #define PAGE (getpagesize ()) | 97 | #define PAGE (getpagesize ()) |
| 98 | #define ALIGNED(addr) (((unsigned long int) (addr) & (page_size - 1)) == 0) | ||
| 99 | #define ROUNDUP(size) (((unsigned long int) (size) + page_size - 1) \ | 98 | #define ROUNDUP(size) (((unsigned long int) (size) + page_size - 1) \ |
| 100 | & ~(page_size - 1)) | 99 | & ~(page_size - 1)) |
| 101 | #define ROUND_TO_PAGE(addr) (addr & (~(page_size - 1))) | ||
| 102 | 100 | ||
| 103 | #define MEM_ALIGN sizeof (double) | 101 | #define MEM_ALIGN sizeof (double) |
| 104 | #define MEM_ROUNDUP(addr) (((unsigned long int)(addr) + MEM_ALIGN - 1) \ | 102 | #define MEM_ROUNDUP(addr) (((unsigned long int)(addr) + MEM_ALIGN - 1) \ |
| @@ -151,7 +149,6 @@ typedef struct heap | |||
| 151 | } *heap_ptr; | 149 | } *heap_ptr; |
| 152 | 150 | ||
| 153 | #define NIL_HEAP ((heap_ptr) 0) | 151 | #define NIL_HEAP ((heap_ptr) 0) |
| 154 | #define HEAP_PTR_SIZE (sizeof (struct heap)) | ||
| 155 | 152 | ||
| 156 | /* This is the first heap object. | 153 | /* This is the first heap object. |
| 157 | If we need additional heap objects, each one resides at the beginning of | 154 | If we need additional heap objects, each one resides at the beginning of |
| @@ -366,15 +363,6 @@ relinquish (void) | |||
| 366 | } | 363 | } |
| 367 | } | 364 | } |
| 368 | } | 365 | } |
| 369 | |||
| 370 | /* Return the total size in use by relocating allocator, | ||
| 371 | above where malloc gets space. */ | ||
| 372 | |||
| 373 | long | ||
| 374 | r_alloc_size_in_use (void) | ||
| 375 | { | ||
| 376 | return (char *) break_value - (char *) virtual_break_value; | ||
| 377 | } | ||
| 378 | 366 | ||
| 379 | /* The meat - allocating, freeing, and relocating blocs. */ | 367 | /* The meat - allocating, freeing, and relocating blocs. */ |
| 380 | 368 | ||
| @@ -748,7 +736,7 @@ free_bloc (bloc_ptr bloc) | |||
| 748 | __morecore hook values - in particular, __default_morecore in the | 736 | __morecore hook values - in particular, __default_morecore in the |
| 749 | GNU malloc package. */ | 737 | GNU malloc package. */ |
| 750 | 738 | ||
| 751 | POINTER | 739 | static POINTER |
| 752 | r_alloc_sbrk (long int size) | 740 | r_alloc_sbrk (long int size) |
| 753 | { | 741 | { |
| 754 | register bloc_ptr b; | 742 | register bloc_ptr b; |
| @@ -1014,52 +1002,6 @@ r_re_alloc (POINTER *ptr, SIZE size) | |||
| 1014 | return *ptr; | 1002 | return *ptr; |
| 1015 | } | 1003 | } |
| 1016 | 1004 | ||
| 1017 | /* Disable relocations, after making room for at least SIZE bytes | ||
| 1018 | of non-relocatable heap if possible. The relocatable blocs are | ||
| 1019 | guaranteed to hold still until thawed, even if this means that | ||
| 1020 | malloc must return a null pointer. */ | ||
| 1021 | |||
| 1022 | void | ||
| 1023 | r_alloc_freeze (long int size) | ||
| 1024 | { | ||
| 1025 | if (! r_alloc_initialized) | ||
| 1026 | r_alloc_init (); | ||
| 1027 | |||
| 1028 | /* If already frozen, we can't make any more room, so don't try. */ | ||
| 1029 | if (r_alloc_freeze_level > 0) | ||
| 1030 | size = 0; | ||
| 1031 | /* If we can't get the amount requested, half is better than nothing. */ | ||
| 1032 | while (size > 0 && r_alloc_sbrk (size) == 0) | ||
| 1033 | size /= 2; | ||
| 1034 | ++r_alloc_freeze_level; | ||
| 1035 | if (size > 0) | ||
| 1036 | r_alloc_sbrk (-size); | ||
| 1037 | } | ||
| 1038 | |||
| 1039 | void | ||
| 1040 | r_alloc_thaw (void) | ||
| 1041 | { | ||
| 1042 | |||
| 1043 | if (! r_alloc_initialized) | ||
| 1044 | r_alloc_init (); | ||
| 1045 | |||
| 1046 | if (--r_alloc_freeze_level < 0) | ||
| 1047 | abort (); | ||
| 1048 | |||
| 1049 | /* This frees all unused blocs. It is not too inefficient, as the resize | ||
| 1050 | and memcpy is done only once. Afterwards, all unreferenced blocs are | ||
| 1051 | already shrunk to zero size. */ | ||
| 1052 | if (!r_alloc_freeze_level) | ||
| 1053 | { | ||
| 1054 | bloc_ptr *b = &first_bloc; | ||
| 1055 | while (*b) | ||
| 1056 | if (!(*b)->variable) | ||
| 1057 | free_bloc (*b); | ||
| 1058 | else | ||
| 1059 | b = &(*b)->next; | ||
| 1060 | } | ||
| 1061 | } | ||
| 1062 | |||
| 1063 | 1005 | ||
| 1064 | #if defined (emacs) && defined (DOUG_LEA_MALLOC) | 1006 | #if defined (emacs) && defined (DOUG_LEA_MALLOC) |
| 1065 | 1007 | ||