X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Falloc_entry.c;h=c13f86eeac1b5e736e956c4d0bb3aa884b280fbe;hp=09374d6e77f87181ced81f2d13bc652e3d472b8b;hb=c0e5fbfcce224693b3effdd295ee49b6b761b754;hpb=5c2245b6fc619f8d96ce940281dfbf13b5b8900b;ds=sidebyside diff --git a/ncurses/tinfo/alloc_entry.c b/ncurses/tinfo/alloc_entry.c index 09374d6e..c13f86ee 100644 --- a/ncurses/tinfo/alloc_entry.c +++ b/ncurses/tinfo/alloc_entry.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 1998-2013,2017 Free Software Foundation, Inc. * + * Copyright 2018-2020,2021 Thomas E. Dickey * + * Copyright 1998-2013,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -47,7 +48,7 @@ #include -MODULE_ID("$Id: alloc_entry.c,v 1.61 2017/08/25 09:09:08 tom Exp $") +MODULE_ID("$Id: alloc_entry.c,v 1.66 2021/08/08 00:09:37 tom Exp $") #define ABSENT_OFFSET -1 #define CANCELLED_OFFSET -2 @@ -92,14 +93,14 @@ _nc_copy_entry(ENTRY * oldp) /* save a copy of string in the string buffer */ NCURSES_EXPORT(char *) -_nc_save_str(const char *const string) +_nc_save_str(const char *string) { char *result = 0; size_t old_next_free = next_free; size_t len; if (!VALID_STRING(string)) - return _nc_save_str(""); + string = ""; len = strlen(string) + 1; if (len == 1 && next_free != 0) { @@ -227,13 +228,21 @@ _nc_merge_entry(ENTRY * const target, ENTRY * const source) { TERMTYPE2 *to = &(target->tterm); TERMTYPE2 *from = &(source->tterm); +#if NCURSES_XNAMES + TERMTYPE2 copy; +#endif unsigned i; + if (source == 0 || from == 0 || target == 0 || to == 0) + return; + #if NCURSES_XNAMES + _nc_copy_termtype2(©, from); + from = © _nc_align_termtype(to, from); #endif for_each_boolean(i, from) { - if (to->Booleans[i] != (char) CANCELLED_BOOLEAN) { + if (to->Booleans[i] != (NCURSES_SBOOL) CANCELLED_BOOLEAN) { int mergebool = from->Booleans[i]; if (mergebool == CANCELLED_BOOLEAN) @@ -269,6 +278,16 @@ _nc_merge_entry(ENTRY * const target, ENTRY * const source) to->Strings[i] = mergestring; } } +#if NCURSES_XNAMES + /* Discard the data allocated in _nc_copy_termtype2, but do not use + * _nc_free_termtype2 because that frees the string-table (which is + * not allocated by _nc_copy_termtype2). + */ + free(copy.Booleans); + free(copy.Numbers); + free(copy.Strings); + free(copy.ext_Names); +#endif } #if NO_LEAKS