From patchwork Wed May 31 20:49:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 70415 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D0A1E3857C5A for ; Wed, 31 May 2023 20:49:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D0A1E3857C5A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685566175; bh=zep3v2aPNJ6oc2mJqTREFSDc5a/sYnx1TNYcgjYQVns=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=dZO6zTBqluKk+oLKEygFTC+BmZwrpGDuOHs5D0RPKzQ17KEOomC2J4JOpPJeorl0P QxIdB9Wt/sga8AhUaXvQQTtipRFhdllX5fID+kMNxHibUUmK9jB9WI6dnEKblMpQAz 84y+iROEX4cMHukENIOgtLPiJBd9UkEIbAf+Dp4w= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id C5B143858D20 for ; Wed, 31 May 2023 20:49:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C5B143858D20 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-XS71n-5dNk2NveweyTBWgg-1; Wed, 31 May 2023 16:49:12 -0400 X-MC-Unique: XS71n-5dNk2NveweyTBWgg-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-3062e5d0cd3so31226f8f.3 for ; Wed, 31 May 2023 13:49:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685566151; x=1688158151; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zep3v2aPNJ6oc2mJqTREFSDc5a/sYnx1TNYcgjYQVns=; b=Vqaocsv4/UQo+FzeLaqiMzrbkXJwe9Zm7tM0+DsS0wXkXtXb7AeiU+pkQp41zZzQf3 ikUZKzdDyVcl5o0ZQzKEie9/yg5p3UOs4ApCEoWVmZgU21JAMCCPCN7sPAczKmBV9oqe VukLoLn6/652XOWZvYM6gumotNOhFghSN8fFG06JxGR/4vcV5PRnPXtFcKN1DBxPKFMn hXUvMefuoQAWRGnuRvZEKff/ZWmtY2ptO8n+oaexYOQWjF/kuCMph3ZklSuHlVYUhuj4 0BPvMPZdH4CPLHckpvEm31wn2hO+jEfflUlJg1juiZbKT6an2vSH9WoIpREj3cZdnRAD 4dfg== X-Gm-Message-State: AC+VfDztqN7x05jxCcJvqxa6jgI4L2ykShTm1oMSkXnxWivMi4G8vskK SSKJf80AtKBKDdxbZ4xajIMXCrsCqbLCHcI/hTUOaXX6LLyODMZYXMb/+Mfx4H4FwqQbUOEeZQB WFDd/IzHiQS+87EpjpkRrl0B3IzBsnsGyL1RmBOa5RdfyD8zYjlSUcrqtqS7JGiI7nMzhilowEu 8pC+4ddw== X-Received: by 2002:a5d:490f:0:b0:306:2c16:8359 with SMTP id x15-20020a5d490f000000b003062c168359mr192373wrq.39.1685566150904; Wed, 31 May 2023 13:49:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ78f5GtVPXMgwRqVXJIOMK8Nmio/AoN3UruwvkbhIAltv1Gv4iImuyE9z3ZhsXBfyxlAsSu/A== X-Received: by 2002:a5d:490f:0:b0:306:2c16:8359 with SMTP id x15-20020a5d490f000000b003062c168359mr192366wrq.39.1685566150520; Wed, 31 May 2023 13:49:10 -0700 (PDT) Received: from localhost (11.72.115.87.dyn.plus.net. [87.115.72.11]) by smtp.gmail.com with ESMTPSA id g9-20020a056000118900b0030ae973c2e7sm8006880wrx.83.2023.05.31.13.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 May 2023 13:49:10 -0700 (PDT) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH] gdb/guile: remove some manual xfree calls Date: Wed, 31 May 2023 21:49:07 +0100 Message-Id: <7b0c91bf5633e8c51c80da3df3ce1310367000e2.1685566126.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" While working on another patch I had reason to look at gdbscm_lookup_type, and noticed that we were making some manual calls to xfree. This commit switches to using gdb::unique_xmalloc_ptr which should automate the xfree calls. I don't believe that we were leaking memory before this commit -- this is just a cleanup. There should be no user visible changes after this commit. --- gdb/guile/scm-type.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) base-commit: e9683acf5e51c2bac8aa68d30d9ac3683dddcc7d diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index 033b800d8b0..cf2252c62e0 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -1267,15 +1267,16 @@ static SCM gdbscm_lookup_type (SCM name_scm, SCM rest) { SCM keywords[] = { block_keyword, SCM_BOOL_F }; - char *name; + char *name_str; SCM block_scm = SCM_BOOL_F; int block_arg_pos = -1; const struct block *block = NULL; struct type *type; gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, keywords, "s#O", - name_scm, &name, + name_scm, &name_str, rest, &block_arg_pos, &block_scm); + gdb::unique_xmalloc_ptr name (name_str); if (block_arg_pos != -1) { @@ -1284,13 +1285,9 @@ gdbscm_lookup_type (SCM name_scm, SCM rest) block = bkscm_scm_to_block (block_scm, block_arg_pos, FUNC_NAME, &exception); if (block == NULL) - { - xfree (name); - gdbscm_throw (exception); - } + gdbscm_throw (exception); } - type = tyscm_lookup_typename (name, block); - xfree (name); + type = tyscm_lookup_typename (name.get (), block); if (type != NULL) return tyscm_scm_from_type (type);