Mercurial > emacs
comparison src/alloc.c @ 88123:375f2633d815
New directory
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 08 Sep 2003 11:56:09 +0000 |
parents | 695cf19ef79e |
children | 2f877ed80fa6 |
comparison
equal
deleted
inserted
replaced
52428:27bc8b966642 | 88123:375f2633d815 |
---|---|
550 if (!val && size) memory_full (); | 550 if (!val && size) memory_full (); |
551 return val; | 551 return val; |
552 } | 552 } |
553 | 553 |
554 | 554 |
555 /* Like free but block interrupt input. */ | 555 /* Like free but block interrupt input.. */ |
556 | 556 |
557 void | 557 void |
558 xfree (block) | 558 xfree (block) |
559 POINTER_TYPE *block; | 559 POINTER_TYPE *block; |
560 { | 560 { |
736 allocated_mem_type = type; | 736 allocated_mem_type = type; |
737 #endif | 737 #endif |
738 | 738 |
739 if (!free_ablock) | 739 if (!free_ablock) |
740 { | 740 { |
741 int i; | 741 int i, aligned; |
742 EMACS_INT aligned; /* int gets warning casting to 64-bit pointer. */ | |
743 | 742 |
744 #ifdef DOUG_LEA_MALLOC | 743 #ifdef DOUG_LEA_MALLOC |
745 /* Prevent mmap'ing the chunk. Lisp data may not be mmap'ed | 744 /* Prevent mmap'ing the chunk. Lisp data may not be mmap'ed |
746 because mapped region contents are not preserved in | 745 because mapped region contents are not preserved in |
747 a dumped Emacs. */ | 746 a dumped Emacs. */ |
765 #ifdef DOUG_LEA_MALLOC | 764 #ifdef DOUG_LEA_MALLOC |
766 /* Back to a reasonable maximum of mmap'ed areas. */ | 765 /* Back to a reasonable maximum of mmap'ed areas. */ |
767 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); | 766 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); |
768 #endif | 767 #endif |
769 | 768 |
770 /* If the memory just allocated cannot be addressed thru a Lisp | |
771 object's pointer, and it needs to be, that's equivalent to | |
772 running out of memory. */ | |
773 if (type != MEM_TYPE_NON_LISP) | |
774 { | |
775 Lisp_Object tem; | |
776 char *end = (char *) base + ABLOCKS_BYTES - 1; | |
777 XSETCONS (tem, end); | |
778 if ((char *) XCONS (tem) != end) | |
779 { | |
780 lisp_malloc_loser = base; | |
781 free (base); | |
782 UNBLOCK_INPUT; | |
783 memory_full (); | |
784 } | |
785 } | |
786 | |
787 /* Initialize the blocks and put them on the free list. | 769 /* Initialize the blocks and put them on the free list. |
788 Is `base' was not properly aligned, we can't use the last block. */ | 770 Is `base' was not properly aligned, we can't use the last block. */ |
789 for (i = 0; i < (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1); i++) | 771 for (i = 0; i < (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1); i++) |
790 { | 772 { |
791 abase->blocks[i].abase = abase; | 773 abase->blocks[i].abase = abase; |
803 | 785 |
804 abase = ABLOCK_ABASE (free_ablock); | 786 abase = ABLOCK_ABASE (free_ablock); |
805 ABLOCKS_BUSY (abase) = (struct ablocks *) (2 + (int) ABLOCKS_BUSY (abase)); | 787 ABLOCKS_BUSY (abase) = (struct ablocks *) (2 + (int) ABLOCKS_BUSY (abase)); |
806 val = free_ablock; | 788 val = free_ablock; |
807 free_ablock = free_ablock->x.next_free; | 789 free_ablock = free_ablock->x.next_free; |
790 | |
791 /* If the memory just allocated cannot be addressed thru a Lisp | |
792 object's pointer, and it needs to be, | |
793 that's equivalent to running out of memory. */ | |
794 if (val && type != MEM_TYPE_NON_LISP) | |
795 { | |
796 Lisp_Object tem; | |
797 XSETCONS (tem, (char *) val + nbytes - 1); | |
798 if ((char *) XCONS (tem) != (char *) val + nbytes - 1) | |
799 { | |
800 lisp_malloc_loser = val; | |
801 free (val); | |
802 val = 0; | |
803 } | |
804 } | |
808 | 805 |
809 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK | 806 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK |
810 if (val && type != MEM_TYPE_NON_LISP) | 807 if (val && type != MEM_TYPE_NON_LISP) |
811 mem_insert (val, (char *) val + nbytes, type); | 808 mem_insert (val, (char *) val + nbytes, type); |
812 #endif | 809 #endif |
5025 case Lisp_Misc_Kboard_Objfwd: | 5022 case Lisp_Misc_Kboard_Objfwd: |
5026 /* Don't bother with Lisp_Buffer_Objfwd, | 5023 /* Don't bother with Lisp_Buffer_Objfwd, |
5027 since all markable slots in current buffer marked anyway. */ | 5024 since all markable slots in current buffer marked anyway. */ |
5028 /* Don't need to do Lisp_Objfwd, since the places they point | 5025 /* Don't need to do Lisp_Objfwd, since the places they point |
5029 are protected with staticpro. */ | 5026 are protected with staticpro. */ |
5030 case Lisp_Misc_Save_Value: | |
5031 break; | 5027 break; |
5032 | 5028 |
5033 case Lisp_Misc_Overlay: | 5029 case Lisp_Misc_Overlay: |
5034 { | 5030 { |
5035 struct Lisp_Overlay *ptr = XOVERLAY (obj); | 5031 struct Lisp_Overlay *ptr = XOVERLAY (obj); |
5787 | 5783 |
5788 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES | 5784 #if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES |
5789 defsubr (&Sgc_status); | 5785 defsubr (&Sgc_status); |
5790 #endif | 5786 #endif |
5791 } | 5787 } |
5792 | |
5793 /* arch-tag: 6695ca10-e3c5-4c2c-8bc3-ed26a7dda857 | |
5794 (do not change this comment) */ |