From patchwork Fri Jan 25 13:12:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 215665 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 409A72C0085 for ; Sat, 26 Jan 2013 00:14:41 +1100 (EST) Received: from localhost ([::1]:43108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tyj79-0000io-A2 for incoming@patchwork.ozlabs.org; Fri, 25 Jan 2013 08:14:39 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tyj5p-0007dl-5g for qemu-devel@nongnu.org; Fri, 25 Jan 2013 08:13:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tyj5k-0002E3-Ou for qemu-devel@nongnu.org; Fri, 25 Jan 2013 08:13:16 -0500 Received: from mail-qc0-f181.google.com ([209.85.216.181]:42598) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tyj5k-0002DR-Hh for qemu-devel@nongnu.org; Fri, 25 Jan 2013 08:13:12 -0500 Received: by mail-qc0-f181.google.com with SMTP id x40so158446qcp.40 for ; Fri, 25 Jan 2013 05:13:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=37F9ylYkwdB9kQrT4nRBkakIsxN6i3jzO8qvKNZPsoE=; b=HaJ93XUMGlU/w8o8kiCK5igFASu1SgzLulLY406dSo4PlPRjmskWxGevS6qAgeULWk zEf015dHfGZF9PeShstMVSSu+k0kIjQTr4asO9Dxf/R6HrXC1OyBjCKl+X0fGWEcLZ7V NX3zA9SJymbFxFziTyxWKGMjtn9p/K47EV1q5K0eyL6ELfyn0mu5XAXypxDS8w2Itl5b wvO4slW/0GqbAQDLtVDNM7GiU5MBj8dr/exlOjg/21BAEwdLoC+j7Xb+dhMV5iKs64FL UIr7GkpBS74OKzAkUkbvODkbuCv1JYp0GKZlSAOQJ7rgWYaGH2pdIfxaFdOcZoBZFk7a LChw== X-Received: by 10.49.75.226 with SMTP id f2mr6753856qew.43.1359119592222; Fri, 25 Jan 2013 05:13:12 -0800 (PST) Received: from yakj.usersys.redhat.com (93-34-179-137.ip50.fastwebnet.it. [93.34.179.137]) by mx.google.com with ESMTPS id u8sm416277qeu.2.2013.01.25.05.13.10 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 25 Jan 2013 05:13:11 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 25 Jan 2013 14:12:39 +0100 Message-Id: <1359119559-19075-14-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1359119559-19075-1-git-send-email-pbonzini@redhat.com> References: <1359119559-19075-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.216.181 Cc: afaerber@suse.de Subject: [Qemu-devel] [PATCH v4 13/13] qom: remove object_delete X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This is now unused. Document the initial reference count of an object and when it will be freed/finalized. Signed-off-by: Paolo Bonzini --- include/qom/object.h | 27 ++++++++++----------------- qom/object.c | 7 ------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index 5e8e528..4dbcbe1 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -553,9 +553,9 @@ struct InterfaceClass * object_new: * @typename: The name of the type of the object to instantiate. * - * This function will initialize a new object using heap allocated memory. This - * function should be paired with object_delete() to free the resources - * associated with the object. + * This function will initialize a new object using heap allocated memory. + * The returned object has a reference count of 1, and will be freed when + * the last reference is dropped. * * Returns: The newly allocated and instantiated object. */ @@ -565,30 +565,22 @@ Object *object_new(const char *typename); * object_new_with_type: * @type: The type of the object to instantiate. * - * This function will initialize a new object using heap allocated memory. This - * function should be paired with object_delete() to free the resources - * associated with the object. + * This function will initialize a new object using heap allocated memory. + * The returned object has a reference count of 1, and will be freed when + * the last reference is dropped. * * Returns: The newly allocated and instantiated object. */ Object *object_new_with_type(Type type); /** - * object_delete: - * @obj: The object to free. - * - * Finalize an object and then free the memory associated with it. This should - * be paired with object_new() to free the resources associated with an object. - */ -void object_delete(Object *obj); - -/** * object_initialize_with_type: * @obj: A pointer to the memory to be used for the object. * @type: The type of the object to instantiate. * * This function will initialize an object. The memory for the object should - * have already been allocated. + * have already been allocated. The returned object has a reference count of 1, + * and will be finalized when the last reference is dropped. */ void object_initialize_with_type(void *data, Type type); @@ -598,7 +590,8 @@ void object_initialize_with_type(void *data, Type type); * @typename: The name of the type of the object to instantiate. * * This function will initialize an object. The memory for the object should - * have already been allocated. + * have already been allocated. The returned object has a reference count of 1, + * and will be finalized when the last reference is dropped. */ void object_initialize(void *obj, const char *typename); diff --git a/qom/object.c b/qom/object.c index 1a123da..aa89e21 100644 --- a/qom/object.c +++ b/qom/object.c @@ -417,13 +417,6 @@ Object *object_new(const char *typename) return object_new_with_type(ti); } -void object_delete(Object *obj) -{ - object_unparent(obj); - g_assert(obj->ref == 1); - object_unref(obj); -} - Object *object_dynamic_cast(Object *obj, const char *typename) { if (obj && object_class_dynamic_cast(object_get_class(obj), typename)) {