]> code.delx.au - gnu-emacs/blobdiff - src/buffer.h
Update copyright year to 2015
[gnu-emacs] / src / buffer.h
index fd989925976e6d41ce7153080319d738803758bf..1b2b5b6a1b16e40e65ef2d9f85a5fa57a420c76d 100644 (file)
@@ -1,6 +1,6 @@
 /* Header file for the buffer manipulation primitives.
 
-Copyright (C) 1985-1986, 1993-1995, 1997-2014 Free Software Foundation,
+Copyright (C) 1985-1986, 1993-1995, 1997-2015 Free Software Foundation,
 Inc.
 
 This file is part of GNU Emacs.
@@ -1088,6 +1088,14 @@ extern void mmap_set_vars (bool);
 extern void restore_buffer (Lisp_Object);
 extern void set_buffer_if_live (Lisp_Object);
 
+/* Return B as a struct buffer pointer, defaulting to the current buffer.  */
+
+INLINE struct buffer *
+decode_buffer (Lisp_Object b)
+{
+  return NILP (b) ? current_buffer : (CHECK_BUFFER (b), XBUFFER (b));
+}
+
 /* Set the current buffer to B.
 
    We previously set windows_or_buffers_changed here to invalidate
@@ -1120,15 +1128,15 @@ record_unwind_current_buffer (void)
 #define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp, chrq)                \
   do {                                                                 \
     ptrdiff_t maxlen = 40;                                             \
-    overlays = alloca (maxlen * sizeof *overlays);                     \
-    noverlays = overlays_at (posn, false, &overlays, &maxlen,          \
-                            nextp, NULL, chrq);                        \
-    if (noverlays > maxlen)                                            \
+    SAFE_NALLOCA (overlays, 1, maxlen);                                        \
+    (noverlays) = overlays_at (posn, false, &(overlays), &maxlen,      \
+                              nextp, NULL, chrq);                      \
+    if ((noverlays) > maxlen)                                          \
       {                                                                        \
        maxlen = noverlays;                                             \
-       overlays = alloca (maxlen * sizeof *overlays);                  \
-       noverlays = overlays_at (posn, false, &overlays, &maxlen,       \
-                                nextp, NULL, chrq);                    \
+       SAFE_NALLOCA (overlays, 1, maxlen);                             \
+       (noverlays) = overlays_at (posn, false, &(overlays), &maxlen,   \
+                                  nextp, NULL, chrq);                  \
       }                                                                        \
   } while (false)