X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=ncurses%2Ftinfo%2Falloc_ttype.c;h=ff32770d032db1b7b103eaf3ee6f70f1d8e3e737;hb=d1a029866f6d84087781eaa81de19949d8533426;hp=42ef05f47752b6146ca98d6425afbeb1d3f65cfb;hpb=38586db6a67a76451d06b129676b8ec6727c9521;p=ncurses.git diff --git a/ncurses/tinfo/alloc_ttype.c b/ncurses/tinfo/alloc_ttype.c index 42ef05f4..ff32770d 100644 --- a/ncurses/tinfo/alloc_ttype.c +++ b/ncurses/tinfo/alloc_ttype.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2021,2022 Thomas E. Dickey * + * Copyright 2018-2022,2023 Thomas E. Dickey * * Copyright 1999-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -43,7 +43,7 @@ #include -MODULE_ID("$Id: alloc_ttype.c,v 1.44 2022/06/18 20:40:54 tom Exp $") +MODULE_ID("$Id: alloc_ttype.c,v 1.49 2023/05/27 20:13:10 tom Exp $") #if NCURSES_XNAMES /* @@ -378,8 +378,8 @@ adjust_cancels(TERMTYPE2 *to, TERMTYPE2 *from) int j, k; DEBUG(3, (T_CALLED("adjust_cancels(%s), from(%s)"), - to ? NonNull(to->term_names) : "?", - from ? NonNull(from->term_names) : "?")); + NonNull(to->term_names), + NonNull(from->term_names))); for (j = first; j < last;) { char *name = to->ext_Names[j]; int j_str = to->num_Strings - first - to->ext_Strings; @@ -559,7 +559,7 @@ copy_termtype(TERMTYPE2 *dst, const TERMTYPE2 *src, int mode) } str_size += strlen(src->term_names) + 1; } - for (i = 0; i < STRCOUNT; ++i) { + for_each_string(i, src) { if (VALID_STRING(src->Strings[i])) { if (pass) { strcpy(new_table + str_size, src->Strings[i]); @@ -572,7 +572,8 @@ copy_termtype(TERMTYPE2 *dst, const TERMTYPE2 *src, int mode) dst->str_table = new_table; } else { ++str_size; - new_table = malloc(str_size); + if ((new_table = malloc(str_size)) == NULL) + _nc_err_abort(MSG_NO_MEMORY); } } @@ -653,7 +654,8 @@ copy_termtype(TERMTYPE2 *dst, const TERMTYPE2 *src, int mode) dst->ext_str_table = new_table; } else { ++str_size; - new_table = calloc(str_size, 1); + if ((new_table = calloc(str_size, 1)) == NULL) + _nc_err_abort(MSG_NO_MEMORY); } } } else { @@ -663,9 +665,6 @@ copy_termtype(TERMTYPE2 *dst, const TERMTYPE2 *src, int mode) DEBUG(2, (T_RETURN(""))); } -/* - * This entrypoint is used by tack 1.07 - */ NCURSES_EXPORT(void) _nc_copy_termtype(TERMTYPE *dst, const TERMTYPE *src) {