From nobody Sun Feb 8 12:13:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1596475156; cv=none; d=zohomail.com; s=zohoarc; b=iYb8X6AuRxNoUvUObYk3lfC0cqwRZ8L81qtTcHRUfT7NKx5D074t7F6ccqRBw5U4Ny3BadQi1m7upBW95Hd19gQMFO0NrpGAYc6mZIBHcDXJLsElGZ8XeCgNUfwjGD4ifTWu4KO3g73EsKzO7ZdSppZ12DojNK84owtp44HQu0U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596475156; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=y0R6OBkn91ziA7RMT8tI3pcjgzusL17luMdWeU4Ifg8=; b=NsmJbJ1ONrUBeqQvqipBUPCDTIQ1C3zMJ8fdSqBLynSd1u27qcpGGc5uddEuJRe16j2Y4E0mc/xGMist665QMde5L8LA7XUZcERzZcW55UBHDFYzUKtsqn49iK2sKmCI7BQAe8i1xUwT1hOcZBoSRUgvlpaznqdcN31NRqEVOkE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1596475156525978.0049899663159; Mon, 3 Aug 2020 10:19:16 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-47-5cxW7u9pOsKoGX6k5H2gBA-1; Mon, 03 Aug 2020 13:19:12 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EB386E93D; Mon, 3 Aug 2020 17:19:06 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CAF037852C; Mon, 3 Aug 2020 17:19:06 +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 9881C1800FDE; Mon, 3 Aug 2020 17:19:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 073HJ4ax011057 for ; Mon, 3 Aug 2020 13:19:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 69C987852C; Mon, 3 Aug 2020 17:19:04 +0000 (UTC) Received: from lpt.redhat.com (unknown [10.40.208.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id B95B087E3C for ; Mon, 3 Aug 2020 17:19:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596475155; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=y0R6OBkn91ziA7RMT8tI3pcjgzusL17luMdWeU4Ifg8=; b=aiw+GrepkiXZr07sF+S6e/jxfZMxgG9hiekS48kTYvEDkrjfzJWqGUvRt1o2J9U3RmYBSF mTKSPv6Cn6cSi5+TlXsrkCZN11UNfGO8LSbvRo5MaCXhQhSw3LEpHxjkbjnsdZRODN88FA uJOKGSbkUid9BxVGt8dMjS9FW7ieexo= X-MC-Unique: 5cxW7u9pOsKoGX6k5H2gBA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/3] util: bitmap: use g_new0/g_free Date: Mon, 3 Aug 2020 19:18:53 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: J=C3=A1n Tomko --- src/util/virbitmap.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 4c205016ff..f7dd5d05ad 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -68,13 +68,8 @@ virBitmapNewQuiet(size_t size) =20 sz =3D VIR_DIV_UP(size, VIR_BITMAP_BITS_PER_UNIT); =20 - if (VIR_ALLOC_QUIET(bitmap) < 0) - return NULL; - - if (VIR_ALLOC_N_QUIET(bitmap->map, sz) < 0) { - VIR_FREE(bitmap); - return NULL; - } + bitmap =3D g_new0(virBitmap, 1); + bitmap->map =3D g_new0(unsigned long, sz); =20 bitmap->nbits =3D size; bitmap->map_len =3D sz; @@ -126,10 +121,9 @@ virBitmapNewEmpty(void) void virBitmapFree(virBitmapPtr bitmap) { - if (bitmap) { - VIR_FREE(bitmap->map); - VIR_FREE(bitmap); - } + if (bitmap) + g_free(bitmap->map); + g_free(bitmap); } =20 =20 @@ -779,9 +773,7 @@ virBitmapToData(virBitmapPtr bitmap, else len =3D (len + CHAR_BIT) / CHAR_BIT; =20 - if (VIR_ALLOC_N(*data, len) < 0) - return -1; - + *data =3D g_new0(unsigned char, len); *dataLen =3D len; =20 virBitmapToDataBuf(bitmap, *data, *dataLen); --=20 2.26.2