aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorKarl Heuer1995-07-17 22:10:25 +0000
committerKarl Heuer1995-07-17 22:10:25 +0000
commit3c06d205922b5d07599a0ad906499a3833d6b04b (patch)
treedaa76e886826972c8ba358e2c83a8677877d07a3 /src/alloc.c
parent6030ce6474e4e66cef14c885dd0c96b90497032e (diff)
downloademacs-3c06d205922b5d07599a0ad906499a3833d6b04b.tar.gz
emacs-3c06d205922b5d07599a0ad906499a3833d6b04b.zip
(Flist): Rewritten.
(allocating_for_lisp): New variable. (init_intervals, make_interval, init_symbol, Fmake_symbol) (init_float, make_float, init_cons, Fcons) (allocate_vectorlike, init_marker, allocate_misc) (init_strings, make_uninit_string): Set allocate_misc temporarily.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c70
1 files changed, 50 insertions, 20 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 6783c68da6b..9e2e8d406d7 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -101,6 +101,9 @@ static char *spare_memory;
101/* Number of extra blocks malloc should get when it needs more core. */ 101/* Number of extra blocks malloc should get when it needs more core. */
102static int malloc_hysteresis; 102static int malloc_hysteresis;
103 103
104/* Nonzero when malloc is called for allocating Lisp object space. */
105int allocating_for_lisp;
106
104/* Non-nil means defun should do purecopy on the function definition */ 107/* Non-nil means defun should do purecopy on the function definition */
105Lisp_Object Vpurify_flag; 108Lisp_Object Vpurify_flag;
106 109
@@ -402,8 +405,10 @@ INTERVAL interval_free_list;
402static void 405static void
403init_intervals () 406init_intervals ()
404{ 407{
408 allocating_for_lisp = 1;
405 interval_block 409 interval_block
406 = (struct interval_block *) malloc (sizeof (struct interval_block)); 410 = (struct interval_block *) malloc (sizeof (struct interval_block));
411 allocating_for_lisp = 0;
407 interval_block->next = 0; 412 interval_block->next = 0;
408 bzero (interval_block->intervals, sizeof interval_block->intervals); 413 bzero (interval_block->intervals, sizeof interval_block->intervals);
409 interval_block_index = 0; 414 interval_block_index = 0;
@@ -426,9 +431,12 @@ make_interval ()
426 { 431 {
427 if (interval_block_index == INTERVAL_BLOCK_SIZE) 432 if (interval_block_index == INTERVAL_BLOCK_SIZE)
428 { 433 {
429 register struct interval_block *newi 434 register struct interval_block *newi;
430 = (struct interval_block *) xmalloc (sizeof (struct interval_block)); 435
436 allocating_for_lisp = 1;
437 newi = (struct interval_block *) xmalloc (sizeof (struct interval_block));
431 438
439 allocating_for_lisp = 0;
432 VALIDATE_LISP_STORAGE (newi, sizeof *newi); 440 VALIDATE_LISP_STORAGE (newi, sizeof *newi);
433 newi->next = interval_block; 441 newi->next = interval_block;
434 interval_block = newi; 442 interval_block = newi;
@@ -529,7 +537,9 @@ struct Lisp_Float *float_free_list;
529void 537void
530init_float () 538init_float ()
531{ 539{
540 allocating_for_lisp = 1;
532 float_block = (struct float_block *) malloc (sizeof (struct float_block)); 541 float_block = (struct float_block *) malloc (sizeof (struct float_block));
542 allocating_for_lisp = 0;
533 float_block->next = 0; 543 float_block->next = 0;
534 bzero (float_block->floats, sizeof float_block->floats); 544 bzero (float_block->floats, sizeof float_block->floats);
535 float_block_index = 0; 545 float_block_index = 0;
@@ -559,7 +569,11 @@ make_float (float_value)
559 { 569 {
560 if (float_block_index == FLOAT_BLOCK_SIZE) 570 if (float_block_index == FLOAT_BLOCK_SIZE)
561 { 571 {
562 register struct float_block *new = (struct float_block *) xmalloc (sizeof (struct float_block)); 572 register struct float_block *new;
573
574 allocating_for_lisp = 1;
575 new = (struct float_block *) xmalloc (sizeof (struct float_block));
576 allocating_for_lisp = 0;
563 VALIDATE_LISP_STORAGE (new, sizeof *new); 577 VALIDATE_LISP_STORAGE (new, sizeof *new);
564 new->next = float_block; 578 new->next = float_block;
565 float_block = new; 579 float_block = new;
@@ -602,7 +616,9 @@ struct Lisp_Cons *cons_free_list;
602void 616void
603init_cons () 617init_cons ()
604{ 618{
619 allocating_for_lisp = 1;
605 cons_block = (struct cons_block *) malloc (sizeof (struct cons_block)); 620 cons_block = (struct cons_block *) malloc (sizeof (struct cons_block));
621 allocating_for_lisp = 0;
606 cons_block->next = 0; 622 cons_block->next = 0;
607 bzero (cons_block->conses, sizeof cons_block->conses); 623 bzero (cons_block->conses, sizeof cons_block->conses);
608 cons_block_index = 0; 624 cons_block_index = 0;
@@ -633,7 +649,10 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0,
633 { 649 {
634 if (cons_block_index == CONS_BLOCK_SIZE) 650 if (cons_block_index == CONS_BLOCK_SIZE)
635 { 651 {
636 register struct cons_block *new = (struct cons_block *) xmalloc (sizeof (struct cons_block)); 652 register struct cons_block *new;
653 allocating_for_lisp = 1;
654 new = (struct cons_block *) xmalloc (sizeof (struct cons_block));
655 allocating_for_lisp = 0;
637 VALIDATE_LISP_STORAGE (new, sizeof *new); 656 VALIDATE_LISP_STORAGE (new, sizeof *new);
638 new->next = cons_block; 657 new->next = cons_block;
639 cons_block = new; 658 cons_block = new;
@@ -654,16 +673,10 @@ Any number of arguments, even zero arguments, are allowed.")
654 int nargs; 673 int nargs;
655 register Lisp_Object *args; 674 register Lisp_Object *args;
656{ 675{
657 register Lisp_Object len, val, val_tail; 676 register Lisp_Object val = Qnil;
658 677
659 XSETFASTINT (len, nargs); 678 while (nargs--)
660 val = Fmake_list (len, Qnil); 679 val = Fcons (args[nargs], val);
661 val_tail = val;
662 while (!NILP (val_tail))
663 {
664 XCONS (val_tail)->car = *args++;
665 val_tail = XCONS (val_tail)->cdr;
666 }
667 return val; 680 return val;
668} 681}
669 682
@@ -694,8 +707,10 @@ allocate_vectorlike (len)
694{ 707{
695 struct Lisp_Vector *p; 708 struct Lisp_Vector *p;
696 709
710 allocating_for_lisp = 1;
697 p = (struct Lisp_Vector *)xmalloc (sizeof (struct Lisp_Vector) 711 p = (struct Lisp_Vector *)xmalloc (sizeof (struct Lisp_Vector)
698 + (len - 1) * sizeof (Lisp_Object)); 712 + (len - 1) * sizeof (Lisp_Object));
713 allocating_for_lisp = 0;
699 VALIDATE_LISP_STORAGE (p, 0); 714 VALIDATE_LISP_STORAGE (p, 0);
700 consing_since_gc += (sizeof (struct Lisp_Vector) 715 consing_since_gc += (sizeof (struct Lisp_Vector)
701 + (len - 1) * sizeof (Lisp_Object)); 716 + (len - 1) * sizeof (Lisp_Object));
@@ -801,7 +816,9 @@ struct Lisp_Symbol *symbol_free_list;
801void 816void
802init_symbol () 817init_symbol ()
803{ 818{
819 allocating_for_lisp = 1;
804 symbol_block = (struct symbol_block *) malloc (sizeof (struct symbol_block)); 820 symbol_block = (struct symbol_block *) malloc (sizeof (struct symbol_block));
821 allocating_for_lisp = 0;
805 symbol_block->next = 0; 822 symbol_block->next = 0;
806 bzero (symbol_block->symbols, sizeof symbol_block->symbols); 823 bzero (symbol_block->symbols, sizeof symbol_block->symbols);
807 symbol_block_index = 0; 824 symbol_block_index = 0;
@@ -828,7 +845,10 @@ Its value and function definition are void, and its property list is nil.")
828 { 845 {
829 if (symbol_block_index == SYMBOL_BLOCK_SIZE) 846 if (symbol_block_index == SYMBOL_BLOCK_SIZE)
830 { 847 {
831 struct symbol_block *new = (struct symbol_block *) xmalloc (sizeof (struct symbol_block)); 848 struct symbol_block *new;
849 allocating_for_lisp = 1;
850 new = (struct symbol_block *) xmalloc (sizeof (struct symbol_block));
851 allocating_for_lisp = 0;
832 VALIDATE_LISP_STORAGE (new, sizeof *new); 852 VALIDATE_LISP_STORAGE (new, sizeof *new);
833 new->next = symbol_block; 853 new->next = symbol_block;
834 symbol_block = new; 854 symbol_block = new;
@@ -866,7 +886,9 @@ union Lisp_Misc *marker_free_list;
866void 886void
867init_marker () 887init_marker ()
868{ 888{
889 allocating_for_lisp = 1;
869 marker_block = (struct marker_block *) malloc (sizeof (struct marker_block)); 890 marker_block = (struct marker_block *) malloc (sizeof (struct marker_block));
891 allocating_for_lisp = 0;
870 marker_block->next = 0; 892 marker_block->next = 0;
871 bzero (marker_block->markers, sizeof marker_block->markers); 893 bzero (marker_block->markers, sizeof marker_block->markers);
872 marker_block_index = 0; 894 marker_block_index = 0;
@@ -888,8 +910,10 @@ allocate_misc ()
888 { 910 {
889 if (marker_block_index == MARKER_BLOCK_SIZE) 911 if (marker_block_index == MARKER_BLOCK_SIZE)
890 { 912 {
891 struct marker_block *new 913 struct marker_block *new;
892 = (struct marker_block *) xmalloc (sizeof (struct marker_block)); 914 allocating_for_lisp = 1;
915 new = (struct marker_block *) xmalloc (sizeof (struct marker_block));
916 allocating_for_lisp = 0;
893 VALIDATE_LISP_STORAGE (new, sizeof *new); 917 VALIDATE_LISP_STORAGE (new, sizeof *new);
894 new->next = marker_block; 918 new->next = marker_block;
895 marker_block = new; 919 marker_block = new;
@@ -981,7 +1005,9 @@ struct string_block *large_string_blocks;
981void 1005void
982init_strings () 1006init_strings ()
983{ 1007{
1008 allocating_for_lisp = 1;
984 current_string_block = (struct string_block *) malloc (sizeof (struct string_block)); 1009 current_string_block = (struct string_block *) malloc (sizeof (struct string_block));
1010 allocating_for_lisp = 0;
985 first_string_block = current_string_block; 1011 first_string_block = current_string_block;
986 consing_since_gc += sizeof (struct string_block); 1012 consing_since_gc += sizeof (struct string_block);
987 current_string_block->next = 0; 1013 current_string_block->next = 0;
@@ -1049,8 +1075,10 @@ make_uninit_string (length)
1049 else if (fullsize > STRING_BLOCK_OUTSIZE) 1075 else if (fullsize > STRING_BLOCK_OUTSIZE)
1050 /* This string gets its own string block */ 1076 /* This string gets its own string block */
1051 { 1077 {
1052 register struct string_block *new 1078 register struct string_block *new;
1053 = (struct string_block *) xmalloc (sizeof (struct string_block_head) + fullsize); 1079 allocating_for_lisp = 1;
1080 new = (struct string_block *) xmalloc (sizeof (struct string_block_head) + fullsize);
1081 allocating_for_lisp = 0;
1054 VALIDATE_LISP_STORAGE (new, 0); 1082 VALIDATE_LISP_STORAGE (new, 0);
1055 consing_since_gc += sizeof (struct string_block_head) + fullsize; 1083 consing_since_gc += sizeof (struct string_block_head) + fullsize;
1056 new->pos = fullsize; 1084 new->pos = fullsize;
@@ -1063,8 +1091,10 @@ make_uninit_string (length)
1063 else 1091 else
1064 /* Make a new current string block and start it off with this string */ 1092 /* Make a new current string block and start it off with this string */
1065 { 1093 {
1066 register struct string_block *new 1094 register struct string_block *new;
1067 = (struct string_block *) xmalloc (sizeof (struct string_block)); 1095 allocating_for_lisp = 1;
1096 new = (struct string_block *) xmalloc (sizeof (struct string_block));
1097 allocating_for_lisp = 0;
1068 VALIDATE_LISP_STORAGE (new, sizeof *new); 1098 VALIDATE_LISP_STORAGE (new, sizeof *new);
1069 consing_since_gc += sizeof (struct string_block); 1099 consing_since_gc += sizeof (struct string_block);
1070 current_string_block->next = new; 1100 current_string_block->next = new;