From nobody Sun Feb 8 17:21:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1532174890224411.1631660705; Sat, 21 Jul 2018 05:08:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9C767C04AC50; Sat, 21 Jul 2018 12:08:03 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5AEB35D9C9; Sat, 21 Jul 2018 12:08:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 097404EE11; Sat, 21 Jul 2018 12:08:02 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6LC7kMK016212 for ; Sat, 21 Jul 2018 08:07:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 04E3F300193F; Sat, 21 Jul 2018 12:07:46 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F3098308332E for ; Sat, 21 Jul 2018 12:07:43 +0000 (UTC) Received: from mail-pl0-f50.google.com (mail-pl0-f50.google.com [209.85.160.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF137307D85D for ; Sat, 21 Jul 2018 12:07:32 +0000 (UTC) Received: by mail-pl0-f50.google.com with SMTP id 94-v6so6299532ple.12 for ; Sat, 21 Jul 2018 05:07:32 -0700 (PDT) Received: from centos.localdomain ([42.106.1.69]) by smtp.gmail.com with ESMTPSA id s16-v6sm5861694pfm.114.2018.07.21.05.07.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 Jul 2018 05:07:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=8mjgVQhARDH93FdVWk2/j7oiwNJ0sIyrrFGeuNrkibI=; b=Ev3qmByocawiAQKAEPXzsYo5boh7jYOvmhQUuUBj8tczAC20PhS8F8scS39H0to5cv UcgXOjC5THA7eWXYa1jRp4gdL3/lZpcgtuxk82FvD3I00axwS2zjSa8R9hv7nwzob+jN mN7Od0IaGjTA4avnuY6wZ/7bhF/bhvGLcDm0dcoRWknug5rfw6GjBuQTw4k02VWNOX5h HV5xmQSxHQbNLupw3dECf490EWVUkdl/UeNMcWdjeIDc2XadWW5prfUQZg8XLYoRkGrw 5C2pa6a/5dFBZEuAo5zQZqoO0MiVM5AFCt8xBXbDtg2NHGONI9cLae0PY2+HP6TNQrn7 Py9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=8mjgVQhARDH93FdVWk2/j7oiwNJ0sIyrrFGeuNrkibI=; b=csDWfdEzVI5MXx1FhymA87JZ6cEmdCGdUXShVQ6dTlZ1Z0IvPjOseSlY8/XfYwUwCT X4QHkvlYWSJt9WvmL4XVPq9wegxbx5qKzCEQYZZd4nkPtWUv98egjXQbT4eDUzvfb/Kl thM42wiyimSGkudGQ1rZAOGZLAfYAU3xb/5vMVVKLEqpLfz4sZ5xt28Wjg0bfTg7Ki7v LdW5GwhzM055R69OChhdFfxzTgMC68JNIXR7dcZewMf9TTQ3YPVnTTPS54MrkMkPUVq4 /eSuTYx0/2/FAdbjls4kDPVsWE7bywLkBeuLw8x1XE7D34+piL8RLv42PtfGq7huO2mf 4q7A== X-Gm-Message-State: AOUpUlE61Wm26igdfeG9u/cuLxydRDcNU2fkNIsfxtx3pBaPu3X8Nmwn G3Giq7f0/1/YS1IBf+bbukoWFf1n X-Google-Smtp-Source: AAOMgpeQ91AHnzMxAdpu0ihw2cSK2cTZOJ9rWIS5W25FtJp0YEJr0yjUsmMe5sakIYsNz3lhlyHdVA== X-Received: by 2002:a17:902:301:: with SMTP id 1-v6mr5594308pld.127.1532174852285; Sat, 21 Jul 2018 05:07:32 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 21 Jul 2018 17:36:36 +0530 Message-Id: <1532174832-21644-5-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1532174832-21644-1-git-send-email-skrtbhtngr@gmail.com> References: <1532174832-21644-1-git-send-email-skrtbhtngr@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sat, 21 Jul 2018 12:07:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Sat, 21 Jul 2018 12:07:33 +0000 (UTC) for IP:'209.85.160.50' DOMAIN:'mail-pl0-f50.google.com' HELO:'mail-pl0-f50.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.281 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, T_DKIM_INVALID) 209.85.160.50 mail-pl0-f50.google.com 209.85.160.50 mail-pl0-f50.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 04/40] util: buffer: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Sat, 21 Jul 2018 12:08:09 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Using the new VIR_DEFINE_AUTOPTR_FUNC macro defined in src/util/viralloc.h, define a new wrapper around an existing cleanup function which will be called when a variable declared with VIR_AUTOPTR macro goes out of scope. Also, drop the redundant viralloc.h include, since that has moved from the source module into the header. When variables of type virBufferPtr and virBufferEscapePairPtr are declared using VIR_AUTOPTR, the functions virBufferFreeAndReset and virBufferEscapePairFree, respectively, will be run automatically on them when they go out of scope. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virbuffer.c | 2 +- src/util/virbuffer.h | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c index 8076cd3..65f4a08 100644 --- a/src/util/virbuffer.c +++ b/src/util/virbuffer.c @@ -31,7 +31,6 @@ #define __VIR_BUFFER_C__ =20 #include "virbuffer.h" -#include "viralloc.h" #include "virerror.h" #include "virstring.h" =20 @@ -664,6 +663,7 @@ virBufferEscapePairFree(virBufferEscapePairPtr pair) =20 VIR_FREE(pair); } +VIR_DEFINE_AUTOPTR_FUNC(virBufferEscapePair, virBufferEscapePairFree) =20 =20 /** diff --git a/src/util/virbuffer.h b/src/util/virbuffer.h index e95ee87..3b31060 100644 --- a/src/util/virbuffer.h +++ b/src/util/virbuffer.h @@ -23,10 +23,13 @@ #ifndef __VIR_BUFFER_H__ # define __VIR_BUFFER_H__ =20 -# include "internal.h" - # include =20 +# include "internal.h" + +# include "viralloc.h" + + /** * virBuffer: * @@ -119,4 +122,6 @@ int virBufferGetIndent(const virBuffer *buf, bool dynam= ic); void virBufferTrim(virBufferPtr buf, const char *trim, int len); void virBufferAddStr(virBufferPtr buf, const char *str); =20 +VIR_DEFINE_AUTOPTR_FUNC(virBuffer, virBufferFreeAndReset) + #endif /* __VIR_BUFFER_H__ */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list