aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorMiles Bader2005-01-16 03:40:12 +0000
committerMiles Bader2005-01-16 03:40:12 +0000
commit54c4c5465ff6dcf158fc47b5894a688ec356f900 (patch)
tree7fd504f98080bd7c498874d3662ef67086a09b66 /src/alloc.c
parentd570d39f949427c4a5041375529c3748d72c6e3c (diff)
parent42187e99f8adc31d93d027b9017160731aab8972 (diff)
downloademacs-54c4c5465ff6dcf158fc47b5894a688ec356f900.tar.gz
emacs-54c4c5465ff6dcf158fc47b5894a688ec356f900.zip
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-2
Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-83 - miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-84 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-3 - miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-4 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-5 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-6 - miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-11 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-12 Remove "-face" suffix from lazy-highlight face name * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-13 - miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-16 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-17 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-18 - miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-21 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-22 <no summary provided> * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-23 - miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-39 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-40 Fix regressions from latest reftex update * miles@gnu.org--gnu-2005/gnus--rel--5.10--base-0 tag of miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-82 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-1 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-2 Merge from miles@gnu.org--gnu-2004 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-3 Merge from emacs--cvs-trunk--0
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 6c393e9213b..998f736b9c5 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -103,7 +103,7 @@ extern __malloc_size_t __malloc_extra_blocks;
103 that the backend handles concurrent access to malloc within its own threads 103 that the backend handles concurrent access to malloc within its own threads
104 but Emacs code running in the main thread is not included in that control). 104 but Emacs code running in the main thread is not included in that control).
105 105
106 When UNBLOCK_INPUT is called, revoke_input_signal may be called. If this 106 When UNBLOCK_INPUT is called, reinvoke_input_signal may be called. If this
107 happens in one of the backend threads we will have two threads that tries 107 happens in one of the backend threads we will have two threads that tries
108 to run Emacs code at once, and the code is not prepared for that. 108 to run Emacs code at once, and the code is not prepared for that.
109 To prevent that, we only call BLOCK/UNBLOCK from the main thread. */ 109 To prevent that, we only call BLOCK/UNBLOCK from the main thread. */
@@ -309,6 +309,7 @@ static void mark_glyph_matrix P_ ((struct glyph_matrix *));
309static void mark_face_cache P_ ((struct face_cache *)); 309static void mark_face_cache P_ ((struct face_cache *));
310 310
311#ifdef HAVE_WINDOW_SYSTEM 311#ifdef HAVE_WINDOW_SYSTEM
312extern void mark_fringe_data P_ ((void));
312static void mark_image P_ ((struct image *)); 313static void mark_image P_ ((struct image *));
313static void mark_image_cache P_ ((struct frame *)); 314static void mark_image_cache P_ ((struct frame *));
314#endif /* HAVE_WINDOW_SYSTEM */ 315#endif /* HAVE_WINDOW_SYSTEM */
@@ -704,9 +705,14 @@ overrun_check_free (block)
704 val + osize, 705 val + osize,
705 XMALLOC_OVERRUN_CHECK_SIZE)) 706 XMALLOC_OVERRUN_CHECK_SIZE))
706 abort (); 707 abort ();
708#ifdef XMALLOC_CLEAR_FREE_MEMORY
709 val -= XMALLOC_OVERRUN_CHECK_SIZE;
710 memset (val, 0xff, osize + XMALLOC_OVERRUN_CHECK_SIZE*2);
711#else
707 bzero (val + osize, XMALLOC_OVERRUN_CHECK_SIZE); 712 bzero (val + osize, XMALLOC_OVERRUN_CHECK_SIZE);
708 val -= XMALLOC_OVERRUN_CHECK_SIZE; 713 val -= XMALLOC_OVERRUN_CHECK_SIZE;
709 bzero (val, XMALLOC_OVERRUN_CHECK_SIZE); 714 bzero (val, XMALLOC_OVERRUN_CHECK_SIZE);
715#endif
710 } 716 }
711 717
712 free (val); 718 free (val);
@@ -1113,17 +1119,34 @@ allocate_buffer ()
1113} 1119}
1114 1120
1115 1121
1122#ifndef SYSTEM_MALLOC
1123
1124/* If we released our reserve (due to running out of memory),
1125 and we have a fair amount free once again,
1126 try to set aside another reserve in case we run out once more.
1127
1128 This is called when a relocatable block is freed in ralloc.c. */
1129
1130void
1131refill_memory_reserve ()
1132{
1133 if (spare_memory == 0)
1134 spare_memory = (char *) malloc ((size_t) SPARE_MEMORY);
1135}
1136
1137
1116/* Arranging to disable input signals while we're in malloc. 1138/* Arranging to disable input signals while we're in malloc.
1117 1139
1118 This only works with GNU malloc. To help out systems which can't 1140 This only works with GNU malloc. To help out systems which can't
1119 use GNU malloc, all the calls to malloc, realloc, and free 1141 use GNU malloc, all the calls to malloc, realloc, and free
1120 elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT 1142 elsewhere in the code should be inside a BLOCK_INPUT/UNBLOCK_INPUT
1121 pairs; unfortunately, we have no idea what C library functions 1143 pair; unfortunately, we have no idea what C library functions
1122 might call malloc, so we can't really protect them unless you're 1144 might call malloc, so we can't really protect them unless you're
1123 using GNU malloc. Fortunately, most of the major operating systems 1145 using GNU malloc. Fortunately, most of the major operating systems
1124 can use GNU malloc. */ 1146 can use GNU malloc. */
1125 1147
1126#ifndef SYSTEM_MALLOC 1148#ifndef SYNC_INPUT
1149
1127#ifndef DOUG_LEA_MALLOC 1150#ifndef DOUG_LEA_MALLOC
1128extern void * (*__malloc_hook) P_ ((size_t)); 1151extern void * (*__malloc_hook) P_ ((size_t));
1129extern void * (*__realloc_hook) P_ ((void *, size_t)); 1152extern void * (*__realloc_hook) P_ ((void *, size_t));
@@ -1182,20 +1205,6 @@ emacs_blocked_free (ptr)
1182} 1205}
1183 1206
1184 1207
1185/* If we released our reserve (due to running out of memory),
1186 and we have a fair amount free once again,
1187 try to set aside another reserve in case we run out once more.
1188
1189 This is called when a relocatable block is freed in ralloc.c. */
1190
1191void
1192refill_memory_reserve ()
1193{
1194 if (spare_memory == 0)
1195 spare_memory = (char *) malloc ((size_t) SPARE_MEMORY);
1196}
1197
1198
1199/* This function is the malloc hook that Emacs uses. */ 1208/* This function is the malloc hook that Emacs uses. */
1200 1209
1201static void * 1210static void *
@@ -1347,6 +1356,7 @@ uninterrupt_malloc ()
1347 __realloc_hook = emacs_blocked_realloc; 1356 __realloc_hook = emacs_blocked_realloc;
1348} 1357}
1349 1358
1359#endif /* not SYNC_INPUT */
1350#endif /* not SYSTEM_MALLOC */ 1360#endif /* not SYSTEM_MALLOC */
1351 1361
1352 1362
@@ -4640,7 +4650,7 @@ returns nil, because real GC can't be done. */)
4640 turned off in that buffer. Calling truncate_undo_list on 4650 turned off in that buffer. Calling truncate_undo_list on
4641 Qt tends to return NULL, which effectively turns undo back on. 4651 Qt tends to return NULL, which effectively turns undo back on.
4642 So don't call truncate_undo_list if undo_list is Qt. */ 4652 So don't call truncate_undo_list if undo_list is Qt. */
4643 if (! EQ (nextb->undo_list, Qt)) 4653 if (! NILP (nextb->name) && ! EQ (nextb->undo_list, Qt))
4644 truncate_undo_list (nextb); 4654 truncate_undo_list (nextb);
4645 4655
4646 /* Shrink buffer gaps, but skip indirect and dead buffers. */ 4656 /* Shrink buffer gaps, but skip indirect and dead buffers. */
@@ -4752,6 +4762,10 @@ returns nil, because real GC can't be done. */)
4752 } 4762 }
4753 mark_backtrace (); 4763 mark_backtrace ();
4754 4764
4765#ifdef HAVE_WINDOW_SYSTEM
4766 mark_fringe_data ();
4767#endif
4768
4755#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES 4769#if GC_MARK_STACK == GC_USE_GCPROS_CHECK_ZOMBIES
4756 mark_stack (); 4770 mark_stack ();
4757#endif 4771#endif