changeset 2838:5f6a2d52d2ef

(compute_char_face): Pass 0 as EXTEND arg to overlays_at. Try first with small overlay_vec, then use a big enough one.
author Richard M. Stallman <rms@gnu.org>
date Sun, 16 May 1993 22:31:04 +0000
parents 00f822101e49
children 8c43cc245dd2
files src/xfaces.c
diffstat 1 files changed, 18 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfaces.c	Sun May 16 21:31:39 1993 +0000
+++ b/src/xfaces.c	Sun May 16 22:31:04 1993 +0000
@@ -136,6 +136,8 @@
 /* The number of the face to use to indicate the region.  */
 int region_face;
 
+/* This is what appears in a slot in a face to signify that the face
+   does not specify that display aspect.  */
 #define FACE_DEFAULT (~0)
 
 Lisp_Object Qface, Qwindow, Qpriority;
@@ -638,7 +640,6 @@
   int i, j, noverlays;
   int facecode;
   Lisp_Object *overlay_vec;
-  int len;
   struct sortvec *sortvec;
   Lisp_Object frame;
   int endpos;
@@ -666,10 +667,23 @@
 
   {
     int next_overlay;
+    int len;
 
-    len = 10;
-    overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object));
-    noverlays = overlays_at (pos, &overlay_vec, &len, &next_overlay);
+    /* First try with room for 40 overlays.  */
+    len = 40;
+    overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
+    
+    noverlays = overlays_at (pos, 0, &overlay_vec, &len, &next_overlay);
+
+    /* If there are more than 40,
+       make enough space for all, and try again.  */
+    if (noverlays > len)
+      {
+	len = noverlays;
+	overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
+	noverlays = overlays_at (pos, 0, &overlay_vec, &len, &next_overlay);
+      }
+
     if (next_overlay < endpos)
       endpos = next_overlay;
   }
@@ -763,8 +777,6 @@
 	merge_faces (FRAME_FACES (f) [region_face], &face);
     }
 
-  xfree (overlay_vec);
-
   *endptr = endpos;
 
   return intern_frame_face (f, &face);