AmendHub

Download (as of this amendment):

jcs

/

textview

/

amendments

/

68

TVFindStyle: When creating a new slab, factor in bitmap size

If the bitmap size is bigger than TV_STYLE_SLAB_SIZE, we'll create a
slab that gets overflowed.

jcs made amendment 68 about 1 month ago
--- tv_store.c Wed Sep 30 17:20:26 2026 +++ tv_store.c Wed Oct 14 16:51:42 2026 @@ -252,7 +252,7 @@ TVFindStyle(struct TVRec *tv, struct TVStyle *style) Handle slabh; struct TVSlab *slab; struct TVStyle *tstyle; - short n; + unsigned long size; if (style->loc) return TVGetStyle(tv, style->loc); @@ -306,8 +306,11 @@ create_style: if (slab->pos + sizeof(struct TVStyle) + style->bitmap_data_size > slab->size) { /* need a new slab */ - slabh = TVAllocateSlab(tv, TV_STYLE_SLAB_SIZE, - &tv->first_style_slab, &tv->last_style_slab); + size = TV_STYLE_SLAB_SIZE; + if (sizeof(struct TVStyle) + style->bitmap_data_size > size) + size = sizeof(struct TVStyle) + style->bitmap_data_size; + slabh = TVAllocateSlab(tv, size, &tv->first_style_slab, + &tv->last_style_slab); if (slabh == NULL) return NULL; slab = (struct TVSlab *)*slabh;