aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorDmitry Antipov2012-07-15 15:17:09 +0400
committerDmitry Antipov2012-07-15 15:17:09 +0400
commitfff62aa9aea4f6c2aadcef4cdc203cdf60ba224c (patch)
tree7298cc895d53a62ed0c3d0cf7bfd8910980d0128 /src/alloc.c
parent9730daca4425e2014ff43a3b1b205b598e63c72a (diff)
downloademacs-fff62aa9aea4f6c2aadcef4cdc203cdf60ba224c.tar.gz
emacs-fff62aa9aea4f6c2aadcef4cdc203cdf60ba224c.zip
Cleanup basic allocation variables and functions.
* alloc.c (ignore_warnings, init_intervals, init_float) (init_cons, init_symbol, init_marker): Remove. (interval_block_index): Initialize to INTERVAL_BLOCK_SIZE. (float_block_index): Initialize to FLOAT_BLOCK_SIZE. (cons_block_index): Initialize to CONS_BLOCK_SIZE. (symbol_block_size): Initialize to SYMBOL_BLOCK_SIZE. (marker_block_index): Initialize to MARKER_BLOCK_SIZE. (staticidx, init_alloc_once, init_strings, free_ablock): Remove redundant initialization. * fns.c (init_weak_hash_tables): Remove. * lisp.h (init_weak_hash_tables): Remove prototype.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c97
1 files changed, 6 insertions, 91 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 1df775a093b..39c360a67e7 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -258,11 +258,6 @@ static char *stack_copy;
258static ptrdiff_t stack_copy_size; 258static ptrdiff_t stack_copy_size;
259#endif 259#endif
260 260
261/* Non-zero means ignore malloc warnings. Set during initialization.
262 Currently not used. */
263
264static int ignore_warnings;
265
266static Lisp_Object Qgc_cons_threshold; 261static Lisp_Object Qgc_cons_threshold;
267Lisp_Object Qchar_table_extra_slots; 262Lisp_Object Qchar_table_extra_slots;
268 263
@@ -435,7 +430,7 @@ static Lisp_Object *staticvec[NSTATICS] = {&Vpurify_flag};
435 430
436/* Index of next unused slot in staticvec. */ 431/* Index of next unused slot in staticvec. */
437 432
438static int staticidx = 0; 433static int staticidx;
439 434
440static void *pure_alloc (size_t, int); 435static void *pure_alloc (size_t, int);
441 436
@@ -1481,7 +1476,7 @@ static struct interval_block *interval_block;
1481/* Index in interval_block above of the next unused interval 1476/* Index in interval_block above of the next unused interval
1482 structure. */ 1477 structure. */
1483 1478
1484static int interval_block_index; 1479static int interval_block_index = INTERVAL_BLOCK_SIZE;
1485 1480
1486/* Number of free and live intervals. */ 1481/* Number of free and live intervals. */
1487 1482
@@ -1491,18 +1486,6 @@ static EMACS_INT total_free_intervals, total_intervals;
1491 1486
1492static INTERVAL interval_free_list; 1487static INTERVAL interval_free_list;
1493 1488
1494
1495/* Initialize interval allocation. */
1496
1497static void
1498init_intervals (void)
1499{
1500 interval_block = NULL;
1501 interval_block_index = INTERVAL_BLOCK_SIZE;
1502 interval_free_list = 0;
1503}
1504
1505
1506/* Return a new interval. */ 1489/* Return a new interval. */
1507 1490
1508INTERVAL 1491INTERVAL
@@ -1803,10 +1786,6 @@ static char const string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] =
1803static void 1786static void
1804init_strings (void) 1787init_strings (void)
1805{ 1788{
1806 total_strings = total_free_strings = total_string_size = 0;
1807 oldest_sblock = current_sblock = large_sblocks = NULL;
1808 string_blocks = NULL;
1809 string_free_list = NULL;
1810 empty_unibyte_string = make_pure_string ("", 0, 0, 0); 1789 empty_unibyte_string = make_pure_string ("", 0, 0, 0);
1811 empty_multibyte_string = make_pure_string ("", 0, 0, 1); 1790 empty_multibyte_string = make_pure_string ("", 0, 0, 1);
1812} 1791}
@@ -2590,24 +2569,12 @@ static struct float_block *float_block;
2590 2569
2591/* Index of first unused Lisp_Float in the current float_block. */ 2570/* Index of first unused Lisp_Float in the current float_block. */
2592 2571
2593static int float_block_index; 2572static int float_block_index = FLOAT_BLOCK_SIZE;
2594 2573
2595/* Free-list of Lisp_Floats. */ 2574/* Free-list of Lisp_Floats. */
2596 2575
2597static struct Lisp_Float *float_free_list; 2576static struct Lisp_Float *float_free_list;
2598 2577
2599
2600/* Initialize float allocation. */
2601
2602static void
2603init_float (void)
2604{
2605 float_block = NULL;
2606 float_block_index = FLOAT_BLOCK_SIZE; /* Force alloc of new float_block. */
2607 float_free_list = 0;
2608}
2609
2610
2611/* Return a new float object with value FLOAT_VALUE. */ 2578/* Return a new float object with value FLOAT_VALUE. */
2612 2579
2613Lisp_Object 2580Lisp_Object
@@ -2696,24 +2663,12 @@ static struct cons_block *cons_block;
2696 2663
2697/* Index of first unused Lisp_Cons in the current block. */ 2664/* Index of first unused Lisp_Cons in the current block. */
2698 2665
2699static int cons_block_index; 2666static int cons_block_index = CONS_BLOCK_SIZE;
2700 2667
2701/* Free-list of Lisp_Cons structures. */ 2668/* Free-list of Lisp_Cons structures. */
2702 2669
2703static struct Lisp_Cons *cons_free_list; 2670static struct Lisp_Cons *cons_free_list;
2704 2671
2705
2706/* Initialize cons allocation. */
2707
2708static void
2709init_cons (void)
2710{
2711 cons_block = NULL;
2712 cons_block_index = CONS_BLOCK_SIZE; /* Force alloc of new cons_block. */
2713 cons_free_list = 0;
2714}
2715
2716
2717/* Explicitly free a cons cell by putting it on the free-list. */ 2672/* Explicitly free a cons cell by putting it on the free-list. */
2718 2673
2719void 2674void
@@ -3453,24 +3408,12 @@ struct symbol_block
3453 structure in it. */ 3408 structure in it. */
3454 3409
3455static struct symbol_block *symbol_block; 3410static struct symbol_block *symbol_block;
3456static int symbol_block_index; 3411static int symbol_block_index = SYMBOL_BLOCK_SIZE;
3457 3412
3458/* List of free symbols. */ 3413/* List of free symbols. */
3459 3414
3460static struct Lisp_Symbol *symbol_free_list; 3415static struct Lisp_Symbol *symbol_free_list;
3461 3416
3462
3463/* Initialize symbol allocation. */
3464
3465static void
3466init_symbol (void)
3467{
3468 symbol_block = NULL;
3469 symbol_block_index = SYMBOL_BLOCK_SIZE;
3470 symbol_free_list = 0;
3471}
3472
3473
3474DEFUN ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0, 3417DEFUN ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0,
3475 doc: /* Return a newly allocated uninterned symbol whose name is NAME. 3418 doc: /* Return a newly allocated uninterned symbol whose name is NAME.
3476Its value and function definition are void, and its property list is nil. */) 3419Its value and function definition are void, and its property list is nil. */)
@@ -3554,18 +3497,10 @@ struct marker_block
3554}; 3497};
3555 3498
3556static struct marker_block *marker_block; 3499static struct marker_block *marker_block;
3557static int marker_block_index; 3500static int marker_block_index = MARKER_BLOCK_SIZE;
3558 3501
3559static union Lisp_Misc *marker_free_list; 3502static union Lisp_Misc *marker_free_list;
3560 3503
3561static void
3562init_marker (void)
3563{
3564 marker_block = NULL;
3565 marker_block_index = MARKER_BLOCK_SIZE;
3566 marker_free_list = 0;
3567}
3568
3569/* Return a newly allocated Lisp_Misc object, with no substructure. */ 3504/* Return a newly allocated Lisp_Misc object, with no substructure. */
3570 3505
3571Lisp_Object 3506Lisp_Object
@@ -6713,32 +6648,19 @@ init_alloc_once (void)
6713 /* Used to do Vpurify_flag = Qt here, but Qt isn't set up yet! */ 6648 /* Used to do Vpurify_flag = Qt here, but Qt isn't set up yet! */
6714 purebeg = PUREBEG; 6649 purebeg = PUREBEG;
6715 pure_size = PURESIZE; 6650 pure_size = PURESIZE;
6716 pure_bytes_used = 0;
6717 pure_bytes_used_lisp = pure_bytes_used_non_lisp = 0;
6718 pure_bytes_used_before_overflow = 0;
6719
6720 /* Initialize the list of free aligned blocks. */
6721 free_ablock = NULL;
6722 6651
6723#if GC_MARK_STACK || defined GC_MALLOC_CHECK 6652#if GC_MARK_STACK || defined GC_MALLOC_CHECK
6724 mem_init (); 6653 mem_init ();
6725 Vdead = make_pure_string ("DEAD", 4, 4, 0); 6654 Vdead = make_pure_string ("DEAD", 4, 4, 0);
6726#endif 6655#endif
6727 6656
6728 ignore_warnings = 1;
6729#ifdef DOUG_LEA_MALLOC 6657#ifdef DOUG_LEA_MALLOC
6730 mallopt (M_TRIM_THRESHOLD, 128*1024); /* trim threshold */ 6658 mallopt (M_TRIM_THRESHOLD, 128*1024); /* trim threshold */
6731 mallopt (M_MMAP_THRESHOLD, 64*1024); /* mmap threshold */ 6659 mallopt (M_MMAP_THRESHOLD, 64*1024); /* mmap threshold */
6732 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); /* max. number of mmap'ed areas */ 6660 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); /* max. number of mmap'ed areas */
6733#endif 6661#endif
6734 init_strings (); 6662 init_strings ();
6735 init_cons ();
6736 init_symbol ();
6737 init_marker ();
6738 init_float ();
6739 init_intervals ();
6740 init_vectors (); 6663 init_vectors ();
6741 init_weak_hash_tables ();
6742 6664
6743#ifdef REL_ALLOC 6665#ifdef REL_ALLOC
6744 malloc_hysteresis = 32; 6666 malloc_hysteresis = 32;
@@ -6747,14 +6669,7 @@ init_alloc_once (void)
6747#endif 6669#endif
6748 6670
6749 refill_memory_reserve (); 6671 refill_memory_reserve ();
6750
6751 ignore_warnings = 0;
6752 gcprolist = 0;
6753 byte_stack_list = 0;
6754 staticidx = 0;
6755 consing_since_gc = 0;
6756 gc_cons_threshold = 100000 * sizeof (Lisp_Object); 6672 gc_cons_threshold = 100000 * sizeof (Lisp_Object);
6757 gc_relative_threshold = 0;
6758} 6673}
6759 6674
6760void 6675void