/****************************************************************************
- * Copyright 2018-2020,2021 Thomas E. Dickey *
+ * Copyright 2018-2021,2022 Thomas E. Dickey *
* Copyright 1998-2016,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
#define CUR SP_TERMTYPE
#endif
-MODULE_ID("$Id: lib_color.c,v 1.147 2021/05/08 15:11:48 tom Exp $")
+MODULE_ID("$Id: lib_color.c,v 1.149 2022/04/30 18:36:54 tom Exp $")
#ifdef USE_TERM_DRIVER
#define CanChange InfoOf(SP_PARM).canchange
#define DATA(r,g,b) {r,g,b, 0,0,0, 0}
-#define TYPE_CALLOC(type,elts) typeCalloc(type, (unsigned)(elts))
-
#define MAX_PALETTE 8
#define OkColorHi(n) (((n) < COLORS) && ((n) < maxcolors))
if (init_direct_colors(NCURSES_SP_ARG)) {
result = OK;
} else {
- SP_PARM->_color_table = TYPE_CALLOC(color_t, maxcolors);
+ TYPE_CALLOC(color_t, maxcolors, SP_PARM->_color_table);
if (SP_PARM->_color_table != 0) {
MakeColorPair(SP_PARM->_color_pairs[0],
default_fg(NCURSES_SP_ARG),
have = sp->_pair_limit;
if (sp->_color_pairs == 0) {
- sp->_color_pairs = TYPE_CALLOC(colorpair_t, have);
+ TYPE_CALLOC(colorpair_t, have, sp->_color_pairs);
} else if (have > sp->_pair_alloc) {
#if NCURSES_EXT_COLORS
colorpair_t *next;
_nc_color_content(SCREEN *sp, int color, int *r, int *g, int *b)
{
int result = ERR;
- int maxcolors;
T((T_CALLED("color_content(%p,%d,%p,%p,%p)"),
(void *) sp,
(void *) b));
if (sp != 0) {
- maxcolors = MaxColors;
+ int maxcolors = MaxColors;
if (color >= 0 && OkColorHi(color) && sp->_coloron) {
int c_r, c_g, c_b;