aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorPaul Eggert2011-06-08 11:43:44 -0700
committerPaul Eggert2011-06-08 11:43:44 -0700
commitc0c5c8ae3686b2fced5aed6e2e15d8222382c4b7 (patch)
tree013cc03b12f61806cee56f9b96b5b1acd95179cb /src/alloc.c
parentb643996157ced5daf45752d37ac5bee3a4f4389f (diff)
downloademacs-c0c5c8ae3686b2fced5aed6e2e15d8222382c4b7.tar.gz
emacs-c0c5c8ae3686b2fced5aed6e2e15d8222382c4b7.zip
* alloc.c: Use EMACS_INT, not int, to count objects.
(total_conses, total_markers, total_symbols, total_vector_size) (total_free_conses, total_free_markers, total_free_symbols) (total_free_floats, total_floats, total_free_intervals, total_intervals) (total_strings, total_free_strings): Now EMACS_INT, not int. All uses changed. (Fgarbage_collect): Compute overall total using a double, so that integer overflow is less likely to be a problem. Check for overflow when converting back to an integer.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 1307ad60234..0bfc4c10e74 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -180,9 +180,9 @@ int abort_on_gc;
180 180
181/* Number of live and free conses etc. */ 181/* Number of live and free conses etc. */
182 182
183static int total_conses, total_markers, total_symbols, total_vector_size; 183static EMACS_INT total_conses, total_markers, total_symbols, total_vector_size;
184static int total_free_conses, total_free_markers, total_free_symbols; 184static EMACS_INT total_free_conses, total_free_markers, total_free_symbols;
185static int total_free_floats, total_floats; 185static EMACS_INT total_free_floats, total_floats;
186 186
187/* Points to memory space allocated as "spare", to be freed if we run 187/* Points to memory space allocated as "spare", to be freed if we run
188 out of memory. We keep one large block, four cons-blocks, and 188 out of memory. We keep one large block, four cons-blocks, and
@@ -1338,7 +1338,7 @@ static int interval_block_index;
1338 1338
1339/* Number of free and live intervals. */ 1339/* Number of free and live intervals. */
1340 1340
1341static int total_free_intervals, total_intervals; 1341static EMACS_INT total_free_intervals, total_intervals;
1342 1342
1343/* List of free intervals. */ 1343/* List of free intervals. */
1344 1344
@@ -1593,7 +1593,7 @@ static struct Lisp_String *string_free_list;
1593 1593
1594/* Number of live and free Lisp_Strings. */ 1594/* Number of live and free Lisp_Strings. */
1595 1595
1596static int total_strings, total_free_strings; 1596static EMACS_INT total_strings, total_free_strings;
1597 1597
1598/* Number of bytes used by live strings. */ 1598/* Number of bytes used by live strings. */
1599 1599
@@ -5118,9 +5118,10 @@ returns nil, because real GC can't be done. */)
5118 if (gc_cons_threshold < 10000) 5118 if (gc_cons_threshold < 10000)
5119 gc_cons_threshold = 10000; 5119 gc_cons_threshold = 10000;
5120 5120
5121 gc_relative_threshold = 0;
5121 if (FLOATP (Vgc_cons_percentage)) 5122 if (FLOATP (Vgc_cons_percentage))
5122 { /* Set gc_cons_combined_threshold. */ 5123 { /* Set gc_cons_combined_threshold. */
5123 EMACS_INT tot = 0; 5124 double tot = 0;
5124 5125
5125 tot += total_conses * sizeof (struct Lisp_Cons); 5126 tot += total_conses * sizeof (struct Lisp_Cons);
5126 tot += total_symbols * sizeof (struct Lisp_Symbol); 5127 tot += total_symbols * sizeof (struct Lisp_Symbol);
@@ -5131,10 +5132,15 @@ returns nil, because real GC can't be done. */)
5131 tot += total_intervals * sizeof (struct interval); 5132 tot += total_intervals * sizeof (struct interval);
5132 tot += total_strings * sizeof (struct Lisp_String); 5133 tot += total_strings * sizeof (struct Lisp_String);
5133 5134
5134 gc_relative_threshold = tot * XFLOAT_DATA (Vgc_cons_percentage); 5135 tot *= XFLOAT_DATA (Vgc_cons_percentage);
5136 if (0 < tot)
5137 {
5138 if (tot < TYPE_MAXIMUM (EMACS_INT))
5139 gc_relative_threshold = tot;
5140 else
5141 gc_relative_threshold = TYPE_MAXIMUM (EMACS_INT);
5142 }
5135 } 5143 }
5136 else
5137 gc_relative_threshold = 0;
5138 5144
5139 if (garbage_collection_messages) 5145 if (garbage_collection_messages)
5140 { 5146 {
@@ -5748,7 +5754,7 @@ gc_sweep (void)
5748 register struct cons_block *cblk; 5754 register struct cons_block *cblk;
5749 struct cons_block **cprev = &cons_block; 5755 struct cons_block **cprev = &cons_block;
5750 register int lim = cons_block_index; 5756 register int lim = cons_block_index;
5751 register int num_free = 0, num_used = 0; 5757 EMACS_INT num_free = 0, num_used = 0;
5752 5758
5753 cons_free_list = 0; 5759 cons_free_list = 0;
5754 5760
@@ -5826,7 +5832,7 @@ gc_sweep (void)
5826 register struct float_block *fblk; 5832 register struct float_block *fblk;
5827 struct float_block **fprev = &float_block; 5833 struct float_block **fprev = &float_block;
5828 register int lim = float_block_index; 5834 register int lim = float_block_index;
5829 register int num_free = 0, num_used = 0; 5835 EMACS_INT num_free = 0, num_used = 0;
5830 5836
5831 float_free_list = 0; 5837 float_free_list = 0;
5832 5838
@@ -5873,7 +5879,7 @@ gc_sweep (void)
5873 register struct interval_block *iblk; 5879 register struct interval_block *iblk;
5874 struct interval_block **iprev = &interval_block; 5880 struct interval_block **iprev = &interval_block;
5875 register int lim = interval_block_index; 5881 register int lim = interval_block_index;
5876 register int num_free = 0, num_used = 0; 5882 EMACS_INT num_free = 0, num_used = 0;
5877 5883
5878 interval_free_list = 0; 5884 interval_free_list = 0;
5879 5885
@@ -5923,7 +5929,7 @@ gc_sweep (void)
5923 register struct symbol_block *sblk; 5929 register struct symbol_block *sblk;
5924 struct symbol_block **sprev = &symbol_block; 5930 struct symbol_block **sprev = &symbol_block;
5925 register int lim = symbol_block_index; 5931 register int lim = symbol_block_index;
5926 register int num_free = 0, num_used = 0; 5932 EMACS_INT num_free = 0, num_used = 0;
5927 5933
5928 symbol_free_list = NULL; 5934 symbol_free_list = NULL;
5929 5935
@@ -5988,7 +5994,7 @@ gc_sweep (void)
5988 register struct marker_block *mblk; 5994 register struct marker_block *mblk;
5989 struct marker_block **mprev = &marker_block; 5995 struct marker_block **mprev = &marker_block;
5990 register int lim = marker_block_index; 5996 register int lim = marker_block_index;
5991 register int num_free = 0, num_used = 0; 5997 EMACS_INT num_free = 0, num_used = 0;
5992 5998
5993 marker_free_list = 0; 5999 marker_free_list = 0;
5994 6000