changeset 57277:85230b6628b3

Remove limit on number of bitmaps. (fringe_bitmaps, fringe_faces): Change to pointers. (max_fringe_bitmaps): New var. (Fdefine_fringe_bitmap): Expand fringe_bitmaps and fringe_faces. (init_fringe): Allocate fringe_bitmaps and fringe_faces.
author Kim F. Storm <storm@cua.dk>
date Wed, 29 Sep 2004 14:22:25 +0000
parents db333b320b67
children 4cec0243673a
files src/fringe.c
diffstat 1 files changed, 38 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/fringe.c	Wed Sep 29 14:21:45 2004 +0000
+++ b/src/fringe.c	Wed Sep 29 14:22:25 2004 +0000
@@ -445,8 +445,9 @@
   { FRBITS (zv_bits),                 8, 3, ALIGN_BITMAP_TOP,    0 },
 };
 
-static struct fringe_bitmap *fringe_bitmaps[MAX_FRINGE_BITMAPS];
-static unsigned fringe_faces[MAX_FRINGE_BITMAPS];
+static struct fringe_bitmap **fringe_bitmaps;
+static unsigned *fringe_faces;
+static int max_fringe_bitmaps;
 
 static int max_used_fringe_bitmap = MAX_STANDARD_FRINGE_BITMAPS;
 
@@ -1192,8 +1193,6 @@
 
   CHECK_SYMBOL (bitmap);
 
-  n = lookup_fringe_bitmap (bitmap);
-
   if (!STRINGP (bits) && !VECTORP (bits))
     bits = wrong_type_argument (Qstringp, bits);
 
@@ -1245,19 +1244,38 @@
   else if (!NILP (align) && !EQ (align, Qcenter))
     error ("Bad align argument");
 
+  n = lookup_fringe_bitmap (bitmap);
   if (!n)
     {
-      if (max_used_fringe_bitmap < MAX_FRINGE_BITMAPS)
+      if (max_used_fringe_bitmap < max_fringe_bitmaps)
 	n = max_used_fringe_bitmap++;
       else
 	{
 	  for (n = MAX_STANDARD_FRINGE_BITMAPS;
-	       n < MAX_FRINGE_BITMAPS;
+	       n < max_fringe_bitmaps;
 	       n++)
 	    if (fringe_bitmaps[n] == NULL)
 	      break;
-	  if (n == MAX_FRINGE_BITMAPS)
-	    error ("Cannot define more fringe bitmaps");
+
+	  if (n == max_fringe_bitmaps)
+	    {
+	      if ((max_fringe_bitmaps + 20) > MAX_FRINGE_BITMAPS)
+		error ("No free fringe bitmap slots");
+
+	      i = max_fringe_bitmaps;
+	      max_fringe_bitmaps += 20;
+	      fringe_bitmaps
+		= ((struct fringe_bitmap **)
+		   xrealloc (fringe_bitmaps, max_fringe_bitmaps * sizeof (struct fringe_bitmap *)));
+	      fringe_faces
+		= (unsigned *) xrealloc (fringe_faces, max_fringe_bitmaps * sizeof (unsigned));
+
+	      for (; i < max_fringe_bitmaps; i++)
+		{
+		  fringe_bitmaps[i] = NULL;
+		  fringe_faces[i] = FRINGE_FACE_ID;
+		}
+	    }
 	}
 
       Vfringe_bitmaps = Fcons (bitmap, Vfringe_bitmaps);
@@ -1405,9 +1423,18 @@
 {
   int i;
 
-  bzero (fringe_bitmaps, sizeof fringe_bitmaps);
-  for (i = 0; i < MAX_FRINGE_BITMAPS; i++)
-    fringe_faces[i] = FRINGE_FACE_ID;
+  max_fringe_bitmaps = MAX_STANDARD_FRINGE_BITMAPS + 20;
+
+  fringe_bitmaps
+    = (struct fringe_bitmap **) xmalloc (max_fringe_bitmaps * sizeof (struct fringe_bitmap *));
+  fringe_faces
+    = (unsigned *) xmalloc (max_fringe_bitmaps * sizeof (unsigned));
+
+  for (i = 0; i < max_fringe_bitmaps; i++)
+    {
+      fringe_bitmaps[i] = NULL;
+      fringe_faces[i] = FRINGE_FACE_ID;
+    }
 }
 
 #ifdef HAVE_NTGUI