aboutsummaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorKenichi Handa2012-08-28 22:44:20 +0900
committerKenichi Handa2012-08-28 22:44:20 +0900
commit4eb4de01df384be9b8d811f7ab476eeb37ece748 (patch)
treed04f0dae31dd8b533a0c3cd738430841ce7ebb84 /src/buffer.c
parentfabc1281e9cde34ff9a19d843316d2ceca8647ad (diff)
parent4f2daf31078e2cc059710e129dffe0beed8fc7c2 (diff)
downloademacs-4eb4de01df384be9b8d811f7ab476eeb37ece748.tar.gz
emacs-4eb4de01df384be9b8d811f7ab476eeb37ece748.zip
merge trunk
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c146
1 files changed, 59 insertions, 87 deletions
diff --git a/src/buffer.c b/src/buffer.c
index c900ef8c5a8..0e2e50d9f51 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -110,10 +110,10 @@ static char buffer_permanent_local_flags[MAX_PER_BUFFER_VARS];
110int last_per_buffer_idx; 110int last_per_buffer_idx;
111 111
112static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, 112static void call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay,
113 int after, Lisp_Object arg1, 113 bool after, Lisp_Object arg1,
114 Lisp_Object arg2, Lisp_Object arg3); 114 Lisp_Object arg2, Lisp_Object arg3);
115static void swap_out_buffer_local_variables (struct buffer *b); 115static void swap_out_buffer_local_variables (struct buffer *b);
116static void reset_buffer_local_variables (struct buffer *b, int permanent_too); 116static void reset_buffer_local_variables (struct buffer *, bool);
117 117
118/* Alist of all buffer names vs the buffers. */ 118/* Alist of all buffer names vs the buffers. */
119/* This used to be a variable, but is no longer, 119/* This used to be a variable, but is no longer,
@@ -155,7 +155,7 @@ static void alloc_buffer_text (struct buffer *, ptrdiff_t);
155static void free_buffer_text (struct buffer *b); 155static void free_buffer_text (struct buffer *b);
156static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay *); 156static struct Lisp_Overlay * copy_overlays (struct buffer *, struct Lisp_Overlay *);
157static void modify_overlay (struct buffer *, ptrdiff_t, ptrdiff_t); 157static void modify_overlay (struct buffer *, ptrdiff_t, ptrdiff_t);
158static Lisp_Object buffer_lisp_local_variables (struct buffer *, int); 158static Lisp_Object buffer_lisp_local_variables (struct buffer *, bool);
159 159
160/* These setters are used only in this file, so they can be private. */ 160/* These setters are used only in this file, so they can be private. */
161static inline void 161static inline void
@@ -979,15 +979,13 @@ reset_buffer (register struct buffer *b)
979 it does not treat permanent locals consistently. 979 it does not treat permanent locals consistently.
980 Instead, use Fkill_all_local_variables. 980 Instead, use Fkill_all_local_variables.
981 981
982 If PERMANENT_TOO is 1, then we reset permanent 982 If PERMANENT_TOO, reset permanent buffer-local variables.
983 buffer-local variables. If PERMANENT_TOO is 0, 983 If not, preserve those. */
984 we preserve those. */
985 984
986static void 985static void
987reset_buffer_local_variables (register struct buffer *b, int permanent_too) 986reset_buffer_local_variables (struct buffer *b, bool permanent_too)
988{ 987{
989 register int offset; 988 int offset, i;
990 int i;
991 989
992 /* Reset the major mode to Fundamental, together with all the 990 /* Reset the major mode to Fundamental, together with all the
993 things that depend on the major mode. 991 things that depend on the major mode.
@@ -1253,14 +1251,14 @@ buffer_local_value_1 (Lisp_Object variable, Lisp_Object buffer)
1253/* Return an alist of the Lisp-level buffer-local bindings of 1251/* Return an alist of the Lisp-level buffer-local bindings of
1254 buffer BUF. That is, don't include the variables maintained 1252 buffer BUF. That is, don't include the variables maintained
1255 in special slots in the buffer object. 1253 in special slots in the buffer object.
1256 If CLONE is zero elements of the form (VAR . unbound) are replaced 1254 If not CLONE, replace elements of the form (VAR . unbound)
1257 by VAR. */ 1255 by VAR. */
1258 1256
1259static Lisp_Object 1257static Lisp_Object
1260buffer_lisp_local_variables (struct buffer *buf, int clone) 1258buffer_lisp_local_variables (struct buffer *buf, bool clone)
1261{ 1259{
1262 Lisp_Object result = Qnil; 1260 Lisp_Object result = Qnil;
1263 register Lisp_Object tail; 1261 Lisp_Object tail;
1264 for (tail = BVAR (buf, local_var_alist); CONSP (tail); tail = XCDR (tail)) 1262 for (tail = BVAR (buf, local_var_alist); CONSP (tail); tail = XCDR (tail))
1265 { 1263 {
1266 Lisp_Object val, elt; 1264 Lisp_Object val, elt;
@@ -1351,11 +1349,9 @@ DEFUN ("set-buffer-modified-p", Fset_buffer_modified_p, Sset_buffer_modified_p,
1351 1, 1, 0, 1349 1, 1, 0,
1352 doc: /* Mark current buffer as modified or unmodified according to FLAG. 1350 doc: /* Mark current buffer as modified or unmodified according to FLAG.
1353A non-nil FLAG means mark the buffer modified. */) 1351A non-nil FLAG means mark the buffer modified. */)
1354 (register Lisp_Object flag) 1352 (Lisp_Object flag)
1355{ 1353{
1356 register int already; 1354 Lisp_Object fn, buffer, window;
1357 register Lisp_Object fn;
1358 Lisp_Object buffer, window;
1359 1355
1360#ifdef CLASH_DETECTION 1356#ifdef CLASH_DETECTION
1361 /* If buffer becoming modified, lock the file. 1357 /* If buffer becoming modified, lock the file.
@@ -1365,7 +1361,7 @@ A non-nil FLAG means mark the buffer modified. */)
1365 /* Test buffer-file-name so that binding it to nil is effective. */ 1361 /* Test buffer-file-name so that binding it to nil is effective. */
1366 if (!NILP (fn) && ! NILP (BVAR (current_buffer, filename))) 1362 if (!NILP (fn) && ! NILP (BVAR (current_buffer, filename)))
1367 { 1363 {
1368 already = SAVE_MODIFF < MODIFF; 1364 bool already = SAVE_MODIFF < MODIFF;
1369 if (!already && !NILP (flag)) 1365 if (!already && !NILP (flag))
1370 lock_file (fn); 1366 lock_file (fn);
1371 else if (already && NILP (flag)) 1367 else if (already && NILP (flag))
@@ -1432,7 +1428,7 @@ state of the current buffer. Use with care. */)
1432 /* Test buffer-file-name so that binding it to nil is effective. */ 1428 /* Test buffer-file-name so that binding it to nil is effective. */
1433 if (!NILP (fn) && ! NILP (BVAR (current_buffer, filename))) 1429 if (!NILP (fn) && ! NILP (BVAR (current_buffer, filename)))
1434 { 1430 {
1435 int already = SAVE_MODIFF < MODIFF; 1431 bool already = SAVE_MODIFF < MODIFF;
1436 if (!already && !NILP (flag)) 1432 if (!already && !NILP (flag))
1437 lock_file (fn); 1433 lock_file (fn);
1438 else if (already && NILP (flag)) 1434 else if (already && NILP (flag))
@@ -1557,7 +1553,6 @@ list first, followed by the list of all buffers. If no other buffer
1557exists, return the buffer `*scratch*' (creating it if necessary). */) 1553exists, return the buffer `*scratch*' (creating it if necessary). */)
1558 (register Lisp_Object buffer, Lisp_Object visible_ok, Lisp_Object frame) 1554 (register Lisp_Object buffer, Lisp_Object visible_ok, Lisp_Object frame)
1559{ 1555{
1560 Lisp_Object Fset_buffer_major_mode (Lisp_Object buffer);
1561 Lisp_Object tail, buf, pred; 1556 Lisp_Object tail, buf, pred;
1562 Lisp_Object notsogood = Qnil; 1557 Lisp_Object notsogood = Qnil;
1563 1558
@@ -1628,7 +1623,6 @@ exists, return the buffer `*scratch*' (creating it if necessary). */)
1628Lisp_Object 1623Lisp_Object
1629other_buffer_safely (Lisp_Object buffer) 1624other_buffer_safely (Lisp_Object buffer)
1630{ 1625{
1631 Lisp_Object Fset_buffer_major_mode (Lisp_Object buffer);
1632 Lisp_Object tail, buf; 1626 Lisp_Object tail, buf;
1633 1627
1634 tail = Vbuffer_alist; 1628 tail = Vbuffer_alist;
@@ -1676,7 +1670,7 @@ No argument or nil as argument means do this for the current buffer. */)
1676 1670
1677/* Truncate undo list and shrink the gap of BUFFER. */ 1671/* Truncate undo list and shrink the gap of BUFFER. */
1678 1672
1679int 1673void
1680compact_buffer (struct buffer *buffer) 1674compact_buffer (struct buffer *buffer)
1681{ 1675{
1682 /* Verify indirection counters. */ 1676 /* Verify indirection counters. */
@@ -1718,9 +1712,7 @@ compact_buffer (struct buffer *buffer)
1718 } 1712 }
1719 } 1713 }
1720 buffer->text->compact = buffer->text->modiff; 1714 buffer->text->compact = buffer->text->modiff;
1721 return 1;
1722 } 1715 }
1723 return 0;
1724} 1716}
1725 1717
1726DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0, 1, "bKill buffer: ", 1718DEFUN ("kill-buffer", Fkill_buffer, Skill_buffer, 0, 1, "bKill buffer: ",
@@ -2070,8 +2062,10 @@ the current buffer's major mode. */)
2070 2062
2071 CHECK_BUFFER (buffer); 2063 CHECK_BUFFER (buffer);
2072 2064
2073 if (STRINGP (BVAR (XBUFFER (buffer), name)) 2065 if (NILP (BVAR (XBUFFER (buffer), name)))
2074 && strcmp (SSDATA (BVAR (XBUFFER (buffer), name)), "*scratch*") == 0) 2066 error ("Attempt to set major mode for a dead buffer");
2067
2068 if (strcmp (SSDATA (BVAR (XBUFFER (buffer), name)), "*scratch*") == 0)
2075 function = find_symbol_value (intern ("initial-major-mode")); 2069 function = find_symbol_value (intern ("initial-major-mode"));
2076 else 2070 else
2077 { 2071 {
@@ -2105,22 +2099,6 @@ DEFUN ("current-buffer", Fcurrent_buffer, Scurrent_buffer, 0, 0, 0,
2105 XSETBUFFER (buf, current_buffer); 2099 XSETBUFFER (buf, current_buffer);
2106 return buf; 2100 return buf;
2107} 2101}
2108
2109/* Set the current buffer to B.
2110
2111 We previously set windows_or_buffers_changed here to invalidate
2112 global unchanged information in beg_unchanged and end_unchanged.
2113 This is no longer necessary because we now compute unchanged
2114 information on a buffer-basis. Every action affecting other
2115 windows than the selected one requires a select_window at some
2116 time, and that increments windows_or_buffers_changed. */
2117
2118void
2119set_buffer_internal (register struct buffer *b)
2120{
2121 if (current_buffer != b)
2122 set_buffer_internal_1 (b);
2123}
2124 2102
2125/* Set the current buffer to B, and do not set windows_or_buffers_changed. 2103/* Set the current buffer to B, and do not set windows_or_buffers_changed.
2126 This is used by redisplay. */ 2104 This is used by redisplay. */
@@ -2226,13 +2204,13 @@ ends when the current command terminates. Use `switch-to-buffer' or
2226 return buffer; 2204 return buffer;
2227} 2205}
2228 2206
2229/* Set the current buffer to BUFFER provided it is alive. */ 2207/* Set the current buffer to BUFFER provided if it is alive. */
2230 2208
2231Lisp_Object 2209Lisp_Object
2232set_buffer_if_live (Lisp_Object buffer) 2210set_buffer_if_live (Lisp_Object buffer)
2233{ 2211{
2234 if (! NILP (BVAR (XBUFFER (buffer), name))) 2212 if (! NILP (BVAR (XBUFFER (buffer), name)))
2235 Fset_buffer (buffer); 2213 set_buffer_internal (XBUFFER (buffer));
2236 return Qnil; 2214 return Qnil;
2237} 2215}
2238 2216
@@ -2471,8 +2449,8 @@ current buffer is cleared. */)
2471 struct Lisp_Marker *tail, *markers; 2449 struct Lisp_Marker *tail, *markers;
2472 struct buffer *other; 2450 struct buffer *other;
2473 ptrdiff_t begv, zv; 2451 ptrdiff_t begv, zv;
2474 int narrowed = (BEG != BEGV || Z != ZV); 2452 bool narrowed = (BEG != BEGV || Z != ZV);
2475 int modified_p = !NILP (Fbuffer_modified_p (Qnil)); 2453 bool modified_p = !NILP (Fbuffer_modified_p (Qnil));
2476 Lisp_Object old_undo = BVAR (current_buffer, undo_list); 2454 Lisp_Object old_undo = BVAR (current_buffer, undo_list);
2477 struct gcpro gcpro1; 2455 struct gcpro gcpro1;
2478 2456
@@ -2821,19 +2799,19 @@ swap_out_buffer_local_variables (struct buffer *b)
2821 *VEC_PTR and *LEN_PTR should contain a valid vector and size 2799 *VEC_PTR and *LEN_PTR should contain a valid vector and size
2822 when this function is called. 2800 when this function is called.
2823 2801
2824 If EXTEND is non-zero, we make the vector bigger if necessary. 2802 If EXTEND, make the vector bigger if necessary.
2825 If EXTEND is zero, we never extend the vector, 2803 If not, never extend the vector,
2826 and we store only as many overlays as will fit. 2804 and store only as many overlays as will fit.
2827 But we still return the total number of overlays. 2805 But still return the total number of overlays.
2828 2806
2829 If CHANGE_REQ is true, then any position written into *PREV_PTR or 2807 If CHANGE_REQ, any position written into *PREV_PTR or
2830 *NEXT_PTR is guaranteed to be not equal to POS, unless it is the 2808 *NEXT_PTR is guaranteed to be not equal to POS, unless it is the
2831 default (BEGV or ZV). */ 2809 default (BEGV or ZV). */
2832 2810
2833ptrdiff_t 2811ptrdiff_t
2834overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr, 2812overlays_at (EMACS_INT pos, bool extend, Lisp_Object **vec_ptr,
2835 ptrdiff_t *len_ptr, 2813 ptrdiff_t *len_ptr,
2836 ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr, int change_req) 2814 ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr, bool change_req)
2837{ 2815{
2838 Lisp_Object overlay, start, end; 2816 Lisp_Object overlay, start, end;
2839 struct Lisp_Overlay *tail; 2817 struct Lisp_Overlay *tail;
@@ -2842,7 +2820,7 @@ overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr,
2842 Lisp_Object *vec = *vec_ptr; 2820 Lisp_Object *vec = *vec_ptr;
2843 ptrdiff_t next = ZV; 2821 ptrdiff_t next = ZV;
2844 ptrdiff_t prev = BEGV; 2822 ptrdiff_t prev = BEGV;
2845 int inhibit_storing = 0; 2823 bool inhibit_storing = 0;
2846 2824
2847 for (tail = current_buffer->overlays_before; tail; tail = tail->next) 2825 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
2848 { 2826 {
@@ -2959,13 +2937,13 @@ overlays_at (EMACS_INT pos, int extend, Lisp_Object **vec_ptr,
2959 *VEC_PTR and *LEN_PTR should contain a valid vector and size 2937 *VEC_PTR and *LEN_PTR should contain a valid vector and size
2960 when this function is called. 2938 when this function is called.
2961 2939
2962 If EXTEND is non-zero, we make the vector bigger if necessary. 2940 If EXTEND, make the vector bigger if necessary.
2963 If EXTEND is zero, we never extend the vector, 2941 If not, never extend the vector,
2964 and we store only as many overlays as will fit. 2942 and store only as many overlays as will fit.
2965 But we still return the total number of overlays. */ 2943 But still return the total number of overlays. */
2966 2944
2967static ptrdiff_t 2945static ptrdiff_t
2968overlays_in (EMACS_INT beg, EMACS_INT end, int extend, 2946overlays_in (EMACS_INT beg, EMACS_INT end, bool extend,
2969 Lisp_Object **vec_ptr, ptrdiff_t *len_ptr, 2947 Lisp_Object **vec_ptr, ptrdiff_t *len_ptr,
2970 ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr) 2948 ptrdiff_t *next_ptr, ptrdiff_t *prev_ptr)
2971{ 2949{
@@ -2976,8 +2954,8 @@ overlays_in (EMACS_INT beg, EMACS_INT end, int extend,
2976 Lisp_Object *vec = *vec_ptr; 2954 Lisp_Object *vec = *vec_ptr;
2977 ptrdiff_t next = ZV; 2955 ptrdiff_t next = ZV;
2978 ptrdiff_t prev = BEGV; 2956 ptrdiff_t prev = BEGV;
2979 int inhibit_storing = 0; 2957 bool inhibit_storing = 0;
2980 int end_is_Z = end == Z; 2958 bool end_is_Z = end == Z;
2981 2959
2982 for (tail = current_buffer->overlays_before; tail; tail = tail->next) 2960 for (tail = current_buffer->overlays_before; tail; tail = tail->next)
2983 { 2961 {
@@ -3078,10 +3056,10 @@ overlays_in (EMACS_INT beg, EMACS_INT end, int extend,
3078} 3056}
3079 3057
3080 3058
3081/* Return non-zero if there exists an overlay with a non-nil 3059/* Return true if there exists an overlay with a non-nil
3082 `mouse-face' property overlapping OVERLAY. */ 3060 `mouse-face' property overlapping OVERLAY. */
3083 3061
3084int 3062bool
3085mouse_face_overlay_overlaps (Lisp_Object overlay) 3063mouse_face_overlay_overlaps (Lisp_Object overlay)
3086{ 3064{
3087 ptrdiff_t start = OVERLAY_POSITION (OVERLAY_START (overlay)); 3065 ptrdiff_t start = OVERLAY_POSITION (OVERLAY_START (overlay));
@@ -3110,7 +3088,7 @@ mouse_face_overlay_overlaps (Lisp_Object overlay)
3110 3088
3111 3089
3112/* Fast function to just test if we're at an overlay boundary. */ 3090/* Fast function to just test if we're at an overlay boundary. */
3113int 3091bool
3114overlay_touches_p (ptrdiff_t pos) 3092overlay_touches_p (ptrdiff_t pos)
3115{ 3093{
3116 Lisp_Object overlay; 3094 Lisp_Object overlay;
@@ -3327,7 +3305,7 @@ overlay_strings (ptrdiff_t pos, struct window *w, unsigned char **pstr)
3327 Lisp_Object overlay, window, str; 3305 Lisp_Object overlay, window, str;
3328 struct Lisp_Overlay *ov; 3306 struct Lisp_Overlay *ov;
3329 ptrdiff_t startpos, endpos; 3307 ptrdiff_t startpos, endpos;
3330 int multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); 3308 bool multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters));
3331 3309
3332 overlay_heads.used = overlay_heads.bytes = 0; 3310 overlay_heads.used = overlay_heads.bytes = 0;
3333 overlay_tails.used = overlay_tails.bytes = 0; 3311 overlay_tails.used = overlay_tails.bytes = 0;
@@ -4321,7 +4299,7 @@ VALUE will be returned.*/)
4321 (Lisp_Object overlay, Lisp_Object prop, Lisp_Object value) 4299 (Lisp_Object overlay, Lisp_Object prop, Lisp_Object value)
4322{ 4300{
4323 Lisp_Object tail, buffer; 4301 Lisp_Object tail, buffer;
4324 int changed; 4302 bool changed;
4325 4303
4326 CHECK_OVERLAY (overlay); 4304 CHECK_OVERLAY (overlay);
4327 4305
@@ -4396,7 +4374,7 @@ add_overlay_mod_hooklist (Lisp_Object functionlist, Lisp_Object overlay)
4396 and the insert-after-hooks of overlay ending at START. 4374 and the insert-after-hooks of overlay ending at START.
4397 4375
4398 This is called both before and after the modification. 4376 This is called both before and after the modification.
4399 AFTER is nonzero when we call after the modification. 4377 AFTER is true when we call after the modification.
4400 4378
4401 ARG1, ARG2, ARG3 are arguments to pass to the hook functions. 4379 ARG1, ARG2, ARG3 are arguments to pass to the hook functions.
4402 When AFTER is nonzero, they are the start position, 4380 When AFTER is nonzero, they are the start position,
@@ -4404,13 +4382,13 @@ add_overlay_mod_hooklist (Lisp_Object functionlist, Lisp_Object overlay)
4404 and the length of deleted or replaced old text. */ 4382 and the length of deleted or replaced old text. */
4405 4383
4406void 4384void
4407report_overlay_modification (Lisp_Object start, Lisp_Object end, int after, 4385report_overlay_modification (Lisp_Object start, Lisp_Object end, bool after,
4408 Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3) 4386 Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3)
4409{ 4387{
4410 Lisp_Object prop, overlay; 4388 Lisp_Object prop, overlay;
4411 struct Lisp_Overlay *tail; 4389 struct Lisp_Overlay *tail;
4412 /* 1 if this change is an insertion. */ 4390 /* True if this change is an insertion. */
4413 int insertion = (after ? XFASTINT (arg3) == 0 : EQ (start, end)); 4391 bool insertion = (after ? XFASTINT (arg3) == 0 : EQ (start, end));
4414 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 4392 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
4415 4393
4416 overlay = Qnil; 4394 overlay = Qnil;
@@ -4530,7 +4508,7 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, int after,
4530} 4508}
4531 4509
4532static void 4510static void
4533call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, int after, 4511call_overlay_mod_hooks (Lisp_Object list, Lisp_Object overlay, bool after,
4534 Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3) 4512 Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3)
4535{ 4513{
4536 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; 4514 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
@@ -4689,7 +4667,7 @@ static int mmap_page_size;
4689 4667
4690/* 1 means mmap has been initialized. */ 4668/* 1 means mmap has been initialized. */
4691 4669
4692static int mmap_initialized_p; 4670static bool mmap_initialized_p;
4693 4671
4694/* Value is X rounded up to the next multiple of N. */ 4672/* Value is X rounded up to the next multiple of N. */
4695 4673
@@ -4785,9 +4763,9 @@ mmap_find (void *start, void *end)
4785 4763
4786 4764
4787/* Unmap a region. P is a pointer to the start of the user-araa of 4765/* Unmap a region. P is a pointer to the start of the user-araa of
4788 the region. Value is non-zero if successful. */ 4766 the region. */
4789 4767
4790static int 4768static void
4791mmap_free_1 (struct mmap_region *r) 4769mmap_free_1 (struct mmap_region *r)
4792{ 4770{
4793 if (r->next) 4771 if (r->next)
@@ -4798,24 +4776,19 @@ mmap_free_1 (struct mmap_region *r)
4798 mmap_regions = r->next; 4776 mmap_regions = r->next;
4799 4777
4800 if (munmap (r, r->nbytes_mapped) == -1) 4778 if (munmap (r, r->nbytes_mapped) == -1)
4801 { 4779 fprintf (stderr, "munmap: %s\n", emacs_strerror (errno));
4802 fprintf (stderr, "munmap: %s\n", emacs_strerror (errno));
4803 return 0;
4804 }
4805
4806 return 1;
4807} 4780}
4808 4781
4809 4782
4810/* Enlarge region R by NPAGES pages. NPAGES < 0 means shrink R. 4783/* Enlarge region R by NPAGES pages. NPAGES < 0 means shrink R.
4811 Value is non-zero if successful. */ 4784 Value is true if successful. */
4812 4785
4813static int 4786static bool
4814mmap_enlarge (struct mmap_region *r, int npages) 4787mmap_enlarge (struct mmap_region *r, int npages)
4815{ 4788{
4816 char *region_end = (char *) r + r->nbytes_mapped; 4789 char *region_end = (char *) r + r->nbytes_mapped;
4817 size_t nbytes; 4790 size_t nbytes;
4818 int success = 0; 4791 bool success = 0;
4819 4792
4820 if (npages < 0) 4793 if (npages < 0)
4821 { 4794 {
@@ -4865,17 +4838,16 @@ mmap_enlarge (struct mmap_region *r, int npages)
4865} 4838}
4866 4839
4867 4840
4868/* Set or reset variables holding references to mapped regions. If 4841/* Set or reset variables holding references to mapped regions.
4869 RESTORE_P is zero, set all variables to null. If RESTORE_P is 4842 If not RESTORE_P, set all variables to null. If RESTORE_P, set all
4870 non-zero, set all variables to the start of the user-areas 4843 variables to the start of the user-areas of mapped regions.
4871 of mapped regions.
4872 4844
4873 This function is called from Fdump_emacs to ensure that the dumped 4845 This function is called from Fdump_emacs to ensure that the dumped
4874 Emacs doesn't contain references to memory that won't be mapped 4846 Emacs doesn't contain references to memory that won't be mapped
4875 when Emacs starts. */ 4847 when Emacs starts. */
4876 4848
4877void 4849void
4878mmap_set_vars (int restore_p) 4850mmap_set_vars (bool restore_p)
4879{ 4851{
4880 struct mmap_region *r; 4852 struct mmap_region *r;
4881 4853