From patchwork Thu Jun 23 16:27:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 70769 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp518609qgy; Thu, 23 Jun 2016 09:31:04 -0700 (PDT) X-Received: by 10.28.18.199 with SMTP id 190mr1689002wms.66.1466699463243; Thu, 23 Jun 2016 09:31:03 -0700 (PDT) Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com. [209.132.183.24]) by mx.google.com with ESMTPS id b185si7452432wmd.34.2016.06.23.09.31.02 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 23 Jun 2016 09:31:03 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id u5NGSDmo007434; Thu, 23 Jun 2016 12:28:14 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.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 u5NGRupi020066 for ; Thu, 23 Jun 2016 12:27:56 -0400 Received: from colepc.redhat.com (ovpn-116-65.rdu2.redhat.com [10.10.116.65]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5NGRs9M010505; Thu, 23 Jun 2016 12:27:55 -0400 From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 23 Jun 2016 12:27:45 -0400 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/6] events: Add virObjectEventCallbackFree 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 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com --- src/conf/object_event.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) -- 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/conf/object_event.c b/src/conf/object_event.c index 95bf3e6..1b5a4d0 100644 --- a/src/conf/object_event.c +++ b/src/conf/object_event.c @@ -126,6 +126,22 @@ virObjectEventDispose(void *obj) } /** + * virObjectEventCallbackFree: + * @list: event callback to free + * + * Free the memory in the domain event callback + */ +static void +virObjectEventCallbackFree(virObjectEventCallbackPtr cb) +{ + if (!cb) + return; + + virObjectUnref(cb->conn); + VIR_FREE(cb); +} + +/** * virObjectEventCallbackListFree: * @list: event callback list head * @@ -230,8 +246,7 @@ virObjectEventCallbackListRemoveID(virConnectPtr conn, if (cb->freecb) (*cb->freecb)(cb->opaque); - virObjectUnref(cb->conn); - VIR_FREE(cb); + virObjectEventCallbackFree(cb); VIR_DELETE_ELEMENT(cbList->callbacks, i, cbList->count); return ret; } @@ -280,8 +295,7 @@ virObjectEventCallbackListPurgeMarked(virObjectEventCallbackListPtr cbList) virFreeCallback freecb = cbList->callbacks[n]->freecb; if (freecb) (*freecb)(cbList->callbacks[n]->opaque); - virObjectUnref(cbList->callbacks[n]->conn); - VIR_FREE(cbList->callbacks[n]); + virObjectEventCallbackFree(cbList->callbacks[n]); VIR_DELETE_ELEMENT(cbList->callbacks, n, cbList->count); n--; @@ -441,9 +455,7 @@ virObjectEventCallbackListAddID(virConnectPtr conn, } cleanup: - if (event) - virObjectUnref(event->conn); - VIR_FREE(event); + virObjectEventCallbackFree(event); return ret; }