+ *h = (t % 360);
+}
+
+/*
+ * Change all cells which use(d) a given color pair to force a repaint.
+ */
+NCURSES_EXPORT(void)
+_nc_change_pair(SCREEN *sp, int pair)
+{
+ int y, x;
+
+ if (CurScreen(sp)->_clear)
+ return;
+#if NO_LEAKS
+ if (_nc_globals.leak_checking)
+ return;
+#endif
+
+ for (y = 0; y <= CurScreen(sp)->_maxy; y++) {
+ struct ldat *ptr = &(CurScreen(sp)->_line[y]);
+ bool changed = FALSE;
+ for (x = 0; x <= CurScreen(sp)->_maxx; x++) {
+ if (GetPair(ptr->text[x]) == pair) {
+ /* Set the old cell to zero to ensure it will be
+ updated on the next doupdate() */
+ SetChar(ptr->text[x], 0, 0);
+ CHANGED_CELL(ptr, x);
+ changed = TRUE;
+ }
+ }
+ if (changed)
+ NCURSES_SP_NAME(_nc_make_oldhash) (NCURSES_SP_ARGx y);
+ }
+}
+
+NCURSES_EXPORT(void)
+_nc_reserve_pairs(SCREEN *sp, int want)
+{
+ int have = sp->_pair_alloc;
+
+ if (have == 0)
+ have = 1;
+ while (have <= want)
+ have *= 2;
+ if (have > sp->_pair_limit)
+ have = sp->_pair_limit;
+
+ if (sp->_color_pairs == 0) {
+ sp->_color_pairs = TYPE_CALLOC(colorpair_t, have);
+ } else if (have > sp->_pair_alloc) {
+#if NCURSES_EXT_COLORS
+ colorpair_t *next;
+
+ if ((next = typeCalloc(colorpair_t, have)) == 0)
+ _nc_err_abort(MSG_NO_MEMORY);
+ memcpy(next, sp->_color_pairs, (size_t) sp->_pair_alloc * sizeof(*next));
+ _nc_copy_pairs(sp, next, sp->_color_pairs, sp->_pair_alloc);
+ free(sp->_color_pairs);
+ sp->_color_pairs = next;
+#else
+ TYPE_REALLOC(colorpair_t, have, sp->_color_pairs);
+ if (sp->_color_pairs != 0) {
+ memset(sp->_color_pairs + sp->_pair_alloc, 0,
+ sizeof(colorpair_t) * (size_t) (have - sp->_pair_alloc));
+ }
+#endif
+ }
+ if (sp->_color_pairs != 0) {
+ sp->_pair_alloc = have;
+ }