From nobody Tue Jul 1 05:36:50 2025 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 1531504567936604.1006574200505; Fri, 13 Jul 2018 10:56:07 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49C574DB00; Fri, 13 Jul 2018 17:56:05 +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 EE27010694F0; Fri, 13 Jul 2018 17:56:04 +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 736A14A465; Fri, 13 Jul 2018 17:56:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6DHtggF008373 for ; Fri, 13 Jul 2018 13:55:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id CFAE46148; Fri, 13 Jul 2018 17:55:42 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C632D19489 for ; Fri, 13 Jul 2018 17:55:41 +0000 (UTC) Received: from mail-pf0-f172.google.com (mail-pf0-f172.google.com [209.85.192.172]) (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 23C835D5F8 for ; Fri, 13 Jul 2018 17:55:30 +0000 (UTC) Received: by mail-pf0-f172.google.com with SMTP id j3-v6so23037433pfh.11 for ; Fri, 13 Jul 2018 10:55:30 -0700 (PDT) Received: from centos.localdomain ([42.106.1.21]) by smtp.gmail.com with ESMTPSA id n5-v6sm26866817pgr.24.2018.07.13.10.55.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jul 2018 10:55:28 -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=QNOGJsaOwLv5ll/f1hXgPsw/5lo5hmyp5mJcSTebGVY=; b=MXrg/HuNHOEcwCQmEiZi9Ufl3SfBQXT6mIlK/+zuBkgVo4raiIX4jNjTe3DlIetUO+ tmfEQwS05SPyZFhr95DqIoZtpv/MmhYVdPVVFNFwl9gwjnuTdDCXp+4LHitR1rQH7JnC xfCuIwbz1vvVSLbNai8ulc3TlCnDfMUEEd6h3hqqfGsS2no1JHwyq3Tkl5x5Xz5gDoBt Y6hhWUH/tib7QS5xNwYmGGnp2+LWgX7Y8NuBoUjpQ37oEPbv82VP2e6t46kiu20epoh5 usa6qUXtEAT/Kl2QyFyI0Uc4KrcBilrJqlZDkFyjxDcR4riXcq7eaxH0gQU8Kj5NExMd t2Jg== 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=QNOGJsaOwLv5ll/f1hXgPsw/5lo5hmyp5mJcSTebGVY=; b=cs+QTokwRrPpebLeWoNDZu03rH98uQS/8z8kSmrcYIdQKhol67ZiJteZzfWu8L1lfA ADw/oIlPOlOhQNDIvXKSAjAMXmBWC6a8C8D3t2h7ZrGZYDK2NzIJNmZTRyP0eVhhM5gL zi6t9nPe9y+mXro5rlNfnzlFFE5PvbvdeYc4USRBSyihG3+Xb640Uetw0BRryicjHZNm 8GjLGzk9SG/oVrSnNHq1v4rgwXzvTeUvY2TgvRmAELxjmdzbZuofJ3W6PzID9l9gtkgf Q8WcOqlDkqStpIXvdgHpR/WqqJRraFxbbshcObsPFGqJynbCHTIzU6M1DOHiwSxJAar7 qBYA== X-Gm-Message-State: AOUpUlEC1i/cX9+LUUbIUOI+dWb457R4sVY4d36g2410hxHg5fshNqR1 NVnElieHolwfvApnThaVYbH2/l/e X-Google-Smtp-Source: AAOMgpdL6FdkyOas5cyed9px+putCJov6NBn7uVikIM0/HcShqy/y5lJtAqpKy+V1j7Ee0Pk6GUEcg== X-Received: by 2002:a62:ed5:: with SMTP id 82-v6mr8151990pfo.198.1531504529388; Fri, 13 Jul 2018 10:55:29 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 13 Jul 2018 23:24:41 +0530 Message-Id: <1531504509-7930-4-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1531504509-7930-1-git-send-email-skrtbhtngr@gmail.com> References: <1531504509-7930-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.39]); Fri, 13 Jul 2018 17:55:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 13 Jul 2018 17:55:30 +0000 (UTC) for IP:'209.85.192.172' DOMAIN:'mail-pf0-f172.google.com' HELO:'mail-pf0-f172.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.3 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.192.172 mail-pf0-f172.google.com 209.85.192.172 mail-pf0-f172.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v4 03/31] util: string: 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 13 Jul 2018 17:56:06 +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. Alias virString to (char *) so that the new cleanup macros can be used for a list of strings (char **). When a list of strings (virString *) is declared using VIR_AUTOPTR, the function virStringListFree will be run automatically on it when it goes out of scope. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virstring.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/util/virstring.h b/src/util/virstring.h index 607ae66..726e02b 100644 --- a/src/util/virstring.h +++ b/src/util/virstring.h @@ -25,6 +25,9 @@ # include =20 # include "internal.h" +# include "viralloc.h" + +typedef char *virString; =20 char **virStringSplitCount(const char *string, const char *delim, @@ -309,4 +312,6 @@ int virStringParsePort(const char *str, unsigned int *port) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; =20 +VIR_DEFINE_AUTOPTR_FUNC(virString, virStringListFree) + #endif /* __VIR_STRING_H__ */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list