From ad67849eb360efba2796cf45161f3067ca5d9e48 Mon Sep 17 00:00:00 2001 From: "Kim F. Storm" Date: Wed, 29 Sep 2004 14:22:25 +0000 Subject: [PATCH] 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. --- src/fringe.c | 49 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/src/fringe.c b/src/fringe.c index b971b6d9847..af2d40b7ee2 100644 --- a/src/fringe.c +++ b/src/fringe.c @@ -445,8 +445,9 @@ struct fringe_bitmap standard_bitmaps[MAX_STANDARD_FRINGE_BITMAPS] = { 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 @@ If BITMAP already exists, the existing definition is replaced. */) CHECK_SYMBOL (bitmap); - n = lookup_fringe_bitmap (bitmap); - if (!STRINGP (bits) && !VECTORP (bits)) bits = wrong_type_argument (Qstringp, bits); @@ -1245,19 +1244,38 @@ If BITMAP already exists, the existing definition is replaced. */) 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 @@ init_fringe () { 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 -- 2.39.2