#endif
-MODULE_ID("$Id: new_pair.c,v 1.8 2017/03/10 09:22:50 tom Exp $")
+MODULE_ID("$Id: new_pair.c,v 1.10 2017/03/28 09:14:15 tom Exp $")
#if USE_NEW_PAIR
find.fg = fg;
find.bg = bg;
- if ((pp = tfind(&find, &sp->_ordered_pairs, compare_data)) != 0) {
+ if (sp != 0 &&
+ (pp = tfind(&find, &sp->_ordered_pairs, compare_data)) != 0) {
colorpair_t *temp = *(colorpair_t **) pp;
result = (int) (temp - sp->_color_pairs);
} else {
int pair;
T((T_CALLED("alloc_pair(%d,%d)"), fg, bg));
- if ((pair = _nc_find_color_pair(SP_PARM, fg, bg)) < 0) {
+ if (SP_PARM == 0) {
+ pair = -1;
+ } else if ((pair = _nc_find_color_pair(SP_PARM, fg, bg)) < 0) {
/*
* Check if all of the slots have been used. If not, find one and
* use that.
T(("reusing %d", pair));
}
- if (pair > 0 && pair <= MAX_XCURSES_PAIR) {
- IGNORE_RC(init_pair((short)pair, (short)fg, (short)bg));
- } else {
+ if (_nc_init_pair(SP_PARM, pair, fg, bg) == ERR)
pair = ERR;
- }
}
returnCode(pair);
}
void
_nc_new_pair(void)
{
-};
+}
#endif /* USE_NEW_PAIR */