From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id 807FF3858C33 for ; Sun, 10 Dec 2023 15:20:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 807FF3858C33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 807FF3858C33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702221631; cv=none; b=pzRFMxcC65BtCl++w0hG4KCITDuGbRewodLYI50jumKblGpGrLUEOfIskdYs7jBAdJJTWDN3nuy2J0RppUIaCzZ6YcGEwmYn5jDQl9f1J0u2pMVg2OMoU/EpiMVtDp1eek8nWGNrWQnNFkibgnhZ0+OnFQ2L5MKEZbYMAwe94wg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702221631; c=relaxed/simple; bh=5e8qDzyhG6WUrGs0wT26KTuhFJjuVeyYA78braMGSug=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=GZ1GEy+x6oQ8BEqngeku06wS8iMN2LFrTBrch5rBmsi8iYcq8poRzR/j+4jUXUwSY7OTfW/8GeJUew8JI2dwq8z3qGxVPxQ9sqhmmfQef+64Udh798VgWa8MVXl5J2NXnDnJWf5RfxHE2vs7imLFoqpm6lZpcmMo9xnG52vVzaU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5009a.ext.cloudfilter.net ([10.0.29.176]) by cmsmtp with ESMTPS id C0gNr2RIH8HteCLbXr8LBw; Sun, 10 Dec 2023 15:20:27 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id CLbVrFRsW97pzCLbWrRdIk; Sun, 10 Dec 2023 15:20:26 +0000 X-Authority-Analysis: v=2.4 cv=ULDOoQTy c=1 sm=1 tr=0 ts=6575d73a a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=e2cXIFwxEfEA:10 a=Qbun_eYptAEA:10 a=jQzlo6Yf4zHV-K74fHYA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=yNCCTyICyUllYsQm2SfqJXJ9xgcApjW930oIrQi9O9c=; b=w3qbWsRG/EV1Snhms3dk8r27nZ o0AqTjXo0jAUWtmaf0XeZYM6PzpLkMxpivBd0l5XPXPo50KvQuw+wnxIxidzljbKHGEldPndFIhl4 Rg3H1RlrVv1JG1fywbwxOjfI/; Received: from [198.59.47.65] (port=50966 helo=[192.168.131.83]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rCLbV-0010ms-26 for gdb-patches@sourceware.org; Sun, 10 Dec 2023 08:20:25 -0700 From: Tom Tromey Date: Sun, 10 Dec 2023 08:20:25 -0700 Subject: [PATCH 2/2] Use unique_xmalloc_ptr in explicit_location_spec MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231210-location-stuff-v1-2-9b6ae74fe5b0@tromey.com> References: <20231210-location-stuff-v1-0-9b6ae74fe5b0@tromey.com> In-Reply-To: <20231210-location-stuff-v1-0-9b6ae74fe5b0@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 198.59.47.65 X-Source-L: No X-Exim-ID: 1rCLbV-0010ms-26 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.131.83]) [198.59.47.65]:50966 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfOPDvfIwwcV96emKdIQUD5kZxTLxxfzU6HYVHyUPd5Hcf+nC14ZGm02/heO4gJJK2N9285fMFWLxQlK5DcuNO2ClDegtANrC7nZ0GS6HSLQSwjZk68EH QEOBCWSJgTaAtMnHdbeFXO4t+WwPDVf/kGLkuSXU7ggVt4wwxEtK7LM+n7yPwi9vjLJXj8RZOSG6PlHs/CTDLGaW2T/0dc2JblM= X-Spam-Status: No, score=-3023.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This changes explicit_location_spec to use unique_xmalloc_ptr, removing some manual memory management. --- gdb/breakpoint.c | 5 ++-- gdb/completer.c | 14 +++++---- gdb/linespec.c | 73 +++++++++++++++++++++++++--------------------- gdb/location.c | 30 ++++++++----------- gdb/location.h | 24 +++++++-------- gdb/mi/mi-cmd-break.c | 6 ++-- gdb/python/py-breakpoint.c | 12 ++++---- 7 files changed, 83 insertions(+), 81 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 957bef290f2..bd7f74671ce 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -12890,9 +12890,8 @@ update_static_tracepoint (tracepoint *tp, struct symtab_and_line sal) tp->first_loc ().symtab = sym != NULL ? sal2.symtab : NULL; std::unique_ptr els - (new explicit_location_spec ()); - els->source_filename - = xstrdup (symtab_to_filename_for_display (sal2.symtab)); + (new explicit_location_spec + (symtab_to_filename_for_display (sal2.symtab))); els->line_offset.offset = tp->first_loc ().line_number; els->line_offset.sign = LINE_OFFSET_NONE; diff --git a/gdb/completer.c b/gdb/completer.c index d5799c0d1ff..d69ddcceca9 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -725,7 +725,8 @@ collect_explicit_location_matches (completion_tracker &tracker, { case MATCH_SOURCE: { - const char *source = string_or_empty (explicit_loc->source_filename); + const char *source + = string_or_empty (explicit_loc->source_filename.get ()); completion_list matches = make_source_files_completion_list (source, source); tracker.add_completions (std::move (matches)); @@ -734,10 +735,11 @@ collect_explicit_location_matches (completion_tracker &tracker, case MATCH_FUNCTION: { - const char *function = string_or_empty (explicit_loc->function_name); + const char *function + = string_or_empty (explicit_loc->function_name.get ()); linespec_complete_function (tracker, function, explicit_loc->func_name_match_type, - explicit_loc->source_filename); + explicit_loc->source_filename.get ()); } break; @@ -750,10 +752,10 @@ collect_explicit_location_matches (completion_tracker &tracker, case MATCH_LABEL: { - const char *label = string_or_empty (explicit_loc->label_name); + const char *label = string_or_empty (explicit_loc->label_name.get ()); linespec_complete_label (tracker, language, - explicit_loc->source_filename, - explicit_loc->function_name, + explicit_loc->source_filename.get (), + explicit_loc->function_name.get (), explicit_loc->func_name_match_type, label); } diff --git a/gdb/linespec.c b/gdb/linespec.c index 1643174de88..76a93d7a35b 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1786,7 +1786,7 @@ linespec_parse_basic (linespec_parser *parser) { completion_tracker tmp_tracker; const char *source_filename - = PARSER_EXPLICIT (parser)->source_filename; + = PARSER_EXPLICIT (parser)->source_filename.get (); symbol_name_match_type match_type = PARSER_EXPLICIT (parser)->func_name_match_type; @@ -1806,7 +1806,7 @@ linespec_parse_basic (linespec_parser *parser) } } - PARSER_EXPLICIT (parser)->function_name = name.release (); + PARSER_EXPLICIT (parser)->function_name = std::move (name); } else { @@ -1823,7 +1823,7 @@ linespec_parse_basic (linespec_parser *parser) { PARSER_RESULT (parser)->function_symbols = std::move (symbols); PARSER_RESULT (parser)->minimal_symbols = std::move (minimal_symbols); - PARSER_EXPLICIT (parser)->function_name = name.release (); + PARSER_EXPLICIT (parser)->function_name = std::move (name); } else { @@ -1838,7 +1838,7 @@ linespec_parse_basic (linespec_parser *parser) PARSER_RESULT (parser)->labels.label_symbols = std::move (labels); PARSER_RESULT (parser)->labels.function_symbols = std::move (symbols); - PARSER_EXPLICIT (parser)->label_name = name.release (); + PARSER_EXPLICIT (parser)->label_name = std::move (name); } else if (token.type == LSTOKEN_STRING && *LS_TOKEN_STOKEN (token).ptr == '$') @@ -1851,7 +1851,7 @@ linespec_parse_basic (linespec_parser *parser) { /* The user-specified variable was not valid. Do not throw an error here. parse_linespec will do it for us. */ - PARSER_EXPLICIT (parser)->function_name = name.release (); + PARSER_EXPLICIT (parser)->function_name = std::move (name); return; } } @@ -1861,7 +1861,7 @@ linespec_parse_basic (linespec_parser *parser) an error here. parse_linespec will do it for us. */ /* Save a copy of the name we were trying to lookup. */ - PARSER_EXPLICIT (parser)->function_name = name.release (); + PARSER_EXPLICIT (parser)->function_name = std::move (name); return; } } @@ -1947,13 +1947,14 @@ linespec_parse_basic (linespec_parser *parser) = std::move (labels); PARSER_RESULT (parser)->labels.function_symbols = std::move (symbols); - PARSER_EXPLICIT (parser)->label_name = name.release (); + PARSER_EXPLICIT (parser)->label_name = std::move (name); } else { /* We don't know what it was, but it isn't a label. */ undefined_label_error - (PARSER_EXPLICIT (parser)->function_name, name.get ()); + (PARSER_EXPLICIT (parser)->function_name.get (), + name.get ()); } } @@ -2012,7 +2013,8 @@ canonicalize_linespec (struct linespec_state *state, const linespec *ls) /* No function was specified, so add the symbol name. */ gdb_assert (ls->labels.function_symbols.size () == 1); block_symbol s = ls->labels.function_symbols.front (); - explicit_loc->function_name = xstrdup (s.symbol->natural_name ()); + explicit_loc->function_name + = make_unique_xstrdup (s.symbol->natural_name ()); } } @@ -2143,7 +2145,7 @@ create_sals_line_offset (struct linespec_state *self, { if (ls->explicit_loc.source_filename) throw_error (NOT_FOUND_ERROR, _("No line %d in file \"%s\"."), - val.line, ls->explicit_loc.source_filename); + val.line, ls->explicit_loc.source_filename.get ()); else throw_error (NOT_FOUND_ERROR, _("No line %d in the current file."), val.line); @@ -2289,7 +2291,7 @@ convert_linespec_to_sals (struct linespec_state *state, linespec *ls) form so that displaying SOURCE_FILENAME can follow the current FILENAME_DISPLAY_STRING setting. But as it is used only rarely it has been kept for code simplicity only in absolute form. */ - ls->explicit_loc.source_filename = xstrdup (filename); + ls->explicit_loc.source_filename = make_unique_xstrdup (filename); } } else @@ -2334,7 +2336,8 @@ convert_explicit_location_spec_to_linespec { source_file_not_found_error (source_filename); } - result->explicit_loc.source_filename = xstrdup (source_filename); + result->explicit_loc.source_filename + = make_unique_xstrdup (source_filename); } else { @@ -2352,9 +2355,10 @@ convert_explicit_location_spec_to_linespec if (symbols.empty () && minimal_symbols.empty ()) symbol_not_found_error (function_name, - result->explicit_loc.source_filename); + result->explicit_loc.source_filename.get ()); - result->explicit_loc.function_name = xstrdup (function_name); + result->explicit_loc.function_name + = make_unique_xstrdup (function_name); result->function_symbols = std::move (symbols); result->minimal_symbols = std::move (minimal_symbols); } @@ -2367,10 +2371,10 @@ convert_explicit_location_spec_to_linespec &symbols, label_name); if (labels.empty ()) - undefined_label_error (result->explicit_loc.function_name, + undefined_label_error (result->explicit_loc.function_name.get (), label_name); - result->explicit_loc.label_name = xstrdup (label_name); + result->explicit_loc.label_name = make_unique_xstrdup (label_name); result->labels.label_symbols = labels; result->labels.function_symbols = std::move (symbols); } @@ -2388,10 +2392,10 @@ convert_explicit_location_spec_to_sals const explicit_location_spec *explicit_spec) { convert_explicit_location_spec_to_linespec (self, result, - explicit_spec->source_filename, - explicit_spec->function_name, + explicit_spec->source_filename.get (), + explicit_spec->function_name.get (), explicit_spec->func_name_match_type, - explicit_spec->label_name, + explicit_spec->label_name.get (), explicit_spec->line_offset); return convert_linespec_to_sals (self, result); } @@ -2565,7 +2569,7 @@ parse_linespec (linespec_parser *parser, const char *arg, if (file_exception.reason >= 0) { /* Symtabs were found for the file. Record the filename. */ - PARSER_EXPLICIT (parser)->source_filename = user_filename.release (); + PARSER_EXPLICIT (parser)->source_filename = std::move (user_filename); /* Get the next token. */ token = linespec_lexer_consume_token (parser); @@ -2610,8 +2614,9 @@ parse_linespec (linespec_parser *parser, const char *arg, throw_exception (std::move (file_exception)); /* Otherwise, the symbol is not found. */ - symbol_not_found_error (PARSER_EXPLICIT (parser)->function_name, - PARSER_EXPLICIT (parser)->source_filename); + symbol_not_found_error + (PARSER_EXPLICIT (parser)->function_name.get (), + PARSER_EXPLICIT (parser)->source_filename.get ()); } convert_to_sals: @@ -2928,7 +2933,7 @@ linespec_complete (completion_tracker &tracker, const char *text, { parser.complete_what = linespec_complete_what::NOTHING; - const char *func_name = PARSER_EXPLICIT (&parser)->function_name; + const char *func_name = PARSER_EXPLICIT (&parser)->function_name.get (); std::vector function_symbols; std::vector minimal_symbols; @@ -2985,10 +2990,11 @@ linespec_complete (completion_tracker &tracker, const char *text, const char *word = parser.completion_word; - complete_linespec_component (&parser, tracker, - parser.completion_word, - linespec_complete_what::FUNCTION, - PARSER_EXPLICIT (&parser)->source_filename); + complete_linespec_component + (&parser, tracker, + parser.completion_word, + linespec_complete_what::FUNCTION, + PARSER_EXPLICIT (&parser)->source_filename.get ()); parser.complete_what = linespec_complete_what::NOTHING; @@ -3028,10 +3034,11 @@ linespec_complete (completion_tracker &tracker, const char *text, tracker.advance_custom_word_point_by (parser.completion_word - orig); - complete_linespec_component (&parser, tracker, - parser.completion_word, - parser.complete_what, - PARSER_EXPLICIT (&parser)->source_filename); + complete_linespec_component + (&parser, tracker, + parser.completion_word, + parser.complete_what, + PARSER_EXPLICIT (&parser)->source_filename.get ()); /* If we're past the "filename:function:label:offset" linespec, and didn't find any match, then assume the user might want to create @@ -3335,7 +3342,7 @@ decode_objc (struct linespec_state *self, linespec *ls, const char *arg) memcpy (saved_arg, arg, new_argptr - arg); saved_arg[new_argptr - arg] = '\0'; - ls->explicit_loc.function_name = xstrdup (saved_arg); + ls->explicit_loc.function_name = make_unique_xstrdup (saved_arg); ls->function_symbols = std::move (symbols); ls->minimal_symbols = std::move (minimal_symbols); values = convert_linespec_to_sals (self, ls); @@ -3350,7 +3357,7 @@ decode_objc (struct linespec_state *self, linespec *ls, const char *arg) if (ls->explicit_loc.source_filename) { holder = string_printf ("%s:%s", - ls->explicit_loc.source_filename, + ls->explicit_loc.source_filename.get (), saved_arg); str = holder.c_str (); } diff --git a/gdb/location.c b/gdb/location.c index df9a7d575da..876f13881f6 100644 --- a/gdb/location.c +++ b/gdb/location.c @@ -156,25 +156,19 @@ address_location_spec::compute_string () const return std::string ("*") + addr_string; } -explicit_location_spec::explicit_location_spec () - : location_spec (EXPLICIT_LOCATION_SPEC) +explicit_location_spec::explicit_location_spec (const char *function_name) + : location_spec (EXPLICIT_LOCATION_SPEC), + function_name (maybe_xstrdup (function_name)) { } -explicit_location_spec::~explicit_location_spec () -{ - xfree (source_filename); - xfree (function_name); - xfree (label_name); -} - explicit_location_spec::explicit_location_spec (const explicit_location_spec &other) : location_spec (other), - source_filename (maybe_xstrdup (other.source_filename)), - function_name (maybe_xstrdup (other.function_name)), + source_filename (maybe_xstrdup (other.source_filename.get ())), + function_name (maybe_xstrdup (other.function_name.get ())), func_name_match_type (other.func_name_match_type), - label_name (maybe_xstrdup (other.label_name)), + label_name (maybe_xstrdup (other.label_name.get ())), line_offset (other.line_offset) { } @@ -291,7 +285,7 @@ explicit_to_string_internal (bool as_linespec, { if (!as_linespec) buf.puts ("-source "); - buf.puts (explicit_loc->source_filename); + buf.puts (explicit_loc->source_filename.get ()); need_space = true; } @@ -303,7 +297,7 @@ explicit_to_string_internal (bool as_linespec, buf.puts ("-qualified "); if (!as_linespec) buf.puts ("-function "); - buf.puts (explicit_loc->function_name); + buf.puts (explicit_loc->function_name.get ()); need_space = true; } @@ -313,7 +307,7 @@ explicit_to_string_internal (bool as_linespec, buf.putc (space); if (!as_linespec) buf.puts ("-label "); - buf.puts (explicit_loc->label_name); + buf.puts (explicit_loc->label_name.get ()); need_space = true; } @@ -705,13 +699,13 @@ string_to_explicit_location_spec (const char **argp, { set_oarg (explicit_location_spec_lex_one (argp, language, completion_info)); - locspec->source_filename = oarg.release (); + locspec->source_filename = std::move (oarg); } else if (strncmp (opt.get (), "-function", len) == 0) { set_oarg (explicit_location_spec_lex_one_function (argp, language, completion_info)); - locspec->function_name = oarg.release (); + locspec->function_name = std::move (oarg); } else if (strncmp (opt.get (), "-qualified", len) == 0) { @@ -731,7 +725,7 @@ string_to_explicit_location_spec (const char **argp, { set_oarg (explicit_location_spec_lex_one (argp, language, completion_info)); - locspec->label_name = oarg.release (); + locspec->label_name = std::move (oarg); } /* Only emit an "invalid argument" error for options that look like option strings. */ diff --git a/gdb/location.h b/gdb/location.h index e39a948f680..acbc2860f2d 100644 --- a/gdb/location.h +++ b/gdb/location.h @@ -190,9 +190,12 @@ struct address_location_spec : public location_spec struct explicit_location_spec : public location_spec { - explicit_location_spec (); + explicit explicit_location_spec (const char *function_name); - ~explicit_location_spec (); + explicit_location_spec () + : explicit_location_spec (nullptr) + { + } location_spec_up clone () const override; @@ -203,18 +206,18 @@ struct explicit_location_spec : public location_spec canonicalized/valid. */ std::string to_linespec () const; - /* The source filename. Malloc'd. */ - char *source_filename = nullptr; + /* The source filename. */ + gdb::unique_xmalloc_ptr source_filename; - /* The function name. Malloc'd. */ - char *function_name = nullptr; + /* The function name. */ + gdb::unique_xmalloc_ptr function_name; /* Whether the function name is fully-qualified or not. */ symbol_name_match_type func_name_match_type = symbol_name_match_type::WILD; - /* The name of a label. Malloc'd. */ - char *label_name = nullptr; + /* The name of a label. */ + gdb::unique_xmalloc_ptr label_name; /* A line offset relative to the start of the symbol identified by the above fields or the current symtab @@ -284,10 +287,7 @@ const probe_location_spec * static inline location_spec_up new_explicit_location_spec_function (const char *function_name) { - explicit_location_spec *spec - = new explicit_location_spec (); - spec->function_name - = (function_name != nullptr ? xstrdup (function_name) : nullptr); + explicit_location_spec *spec = new explicit_location_spec (function_name); return location_spec_up (spec); } diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index 44835c7f7d0..a4b62cb6f99 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -267,15 +267,15 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, break; case EXPLICIT_SOURCE_OPT: is_explicit = 1; - explicit_loc->source_filename = xstrdup (oarg); + explicit_loc->source_filename = make_unique_xstrdup (oarg); break; case EXPLICIT_FUNC_OPT: is_explicit = 1; - explicit_loc->function_name = xstrdup (oarg); + explicit_loc->function_name = make_unique_xstrdup (oarg); break; case EXPLICIT_LABEL_OPT: is_explicit = 1; - explicit_loc->label_name = xstrdup (oarg); + explicit_loc->label_name = make_unique_xstrdup (oarg); break; case EXPLICIT_LINE_OPT: is_explicit = 1; diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index 71182cc1b1b..5155d41e675 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -1010,12 +1010,12 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) std::unique_ptr explicit_loc (new explicit_location_spec ()); - explicit_loc->source_filename - = source != nullptr ? xstrdup (source) : nullptr; - explicit_loc->function_name - = function != nullptr ? xstrdup (function) : nullptr; - explicit_loc->label_name - = label != nullptr ? xstrdup (label) : nullptr; + if (source != nullptr) + explicit_loc->source_filename = make_unique_xstrdup (source); + if (function != nullptr) + explicit_loc->function_name = make_unique_xstrdup (function); + if (label != nullptr) + explicit_loc->label_name = make_unique_xstrdup (label); if (line != NULL) explicit_loc->line_offset -- 2.43.0