- if ((SP->_color_pairs = TYPE_CALLOC(colorpair_t,
- max_pairs)) != 0) {
- if ((SP->_color_table = TYPE_CALLOC(color_t,
- max_colors)) != 0) {
- SP->_color_pairs[0] = PAIR_OF(default_fg(), default_bg());
- init_color_table();
+#if NCURSES_EXT_FUNCS
+ /*
+ * If using default colors, allocate extra space in table to
+ * allow for default-color as a component of a color-pair.
+ */
+ SP_PARM->_pair_limit += (1 + (2 * maxcolors));
+#endif
+ SP_PARM->_pair_count = maxpairs;
+ SP_PARM->_color_count = maxcolors;
+#if !USE_REENTRANT
+ COLOR_PAIRS = maxpairs;
+ COLORS = maxcolors;
+#endif
+
+ SP_PARM->_color_pairs = TYPE_CALLOC(colorpair_t, SP_PARM->_pair_limit);
+ if (SP_PARM->_color_pairs != 0) {
+ SP_PARM->_color_table = TYPE_CALLOC(color_t, maxcolors);
+ if (SP_PARM->_color_table != 0) {
+ SP_PARM->_color_pairs[0] = PAIR_OF(default_fg(NCURSES_SP_ARG),
+ default_bg(NCURSES_SP_ARG));
+ init_color_table(NCURSES_SP_ARG);