From nobody Mon Feb 9 11:47:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1625837091; cv=none; d=zohomail.com; s=zohoarc; b=IAX+Z/u80bom+k7B4J9aqTZgEEes8wU3S1V91OirDEftwyW5Tm7EkVwiZvTHCjw8Ly5gZ4JiWtATmCFVHS+9s4CkKOSloJqpS50Sgzbz7mPQhc5mdtVJhdMN0fcxFwWhilpFG2KXFQkgvfiomyPyWw/uqHA+czs9e+lWz5ucM9Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1625837091; h=Content-Type:Content-Transfer-Encoding:Cc: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=wOuJX4KIXFBN4a7eOVrqUKm7M6P8i8D4513RQPCw+NY=; b=DXSkSeaEpPtVkbaZ0gxnd1rRTQyKx1K/dGRKUD9pUi4tcfPUmvfTkLi1ZgqMuMDZKiHwLn48E3tPUAcl9DFjfocBlRFK4PlIpuoLHLMyGR0KWGfqVXU07C5tCgqJSam3+g60yeujYJOzMDZK7e+H9n9EToU3FhCr4ardzP0Yuro= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1625837091493335.65004203966566; Fri, 9 Jul 2021 06:24:51 -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-602-mW52uq1LP72jGayrgL27Ew-1; Fri, 09 Jul 2021 09:24:49 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C19F610C1ADC; Fri, 9 Jul 2021 13:24:43 +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 A0D0D5C1CF; Fri, 9 Jul 2021 13:24:43 +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 662324EA2A; Fri, 9 Jul 2021 13:24:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 169DOflw030542 for ; Fri, 9 Jul 2021 09:24:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 674CF5C23A; Fri, 9 Jul 2021 13:24:41 +0000 (UTC) Received: from work.redhat.com (ovpn-113-189.ams2.redhat.com [10.36.113.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id B50D55C1CF; Fri, 9 Jul 2021 13:24:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1625837090; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=wOuJX4KIXFBN4a7eOVrqUKm7M6P8i8D4513RQPCw+NY=; b=c2EiagDRiMVLIdnfjW74pq/3uFWFJaHATLI6snywwva7KOzmISmXaDcdjbNA1Dmzc/Xsls lcEhKf6wkDl7wB1VhhkzthsrasTB2+zwaYhVs8+arW26N1YyEBPdOB7+DJULq23q6OKPXi Q8ybB4MacERcUiNWyhcCOJNB8v5UGRI= X-MC-Unique: mW52uq1LP72jGayrgL27Ew-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH v2 2/2] viralloc: Delete VIR_INSERT_ELEMENT_COPY and VIR_INSERT_ELEMENT_COPY_INPLACE Date: Fri, 9 Jul 2021 15:23:53 +0200 Message-Id: <20210709132353.80203-3-twiederh@redhat.com> In-Reply-To: <20210709132353.80203-1-twiederh@redhat.com> References: <20210709132353.80203-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.16 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1625837092574100001 Content-Type: text/plain; charset="utf-8" There are no users left. Signed-off-by: Tim Wiederhake --- src/util/viralloc.h | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/src/util/viralloc.h b/src/util/viralloc.h index 553d2951cf..72e8f13bef 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -165,7 +165,7 @@ int virDeleteElementsN(void *ptrptr, size_t size, size_= t at, size_t *countptr, sizeof(char[2 * (sizeof(*(a) =3D *(b)) =3D=3D sizeof(*(b))) - 1]) =20 /** - * VIR_INSERT_ELEMENT: + * VIR_INSERT_ELEMENT, VIR_INSERT_ELEMENT_INPLACE: * @ptr: pointer to array of objects (*not* ptr to ptr) * @at: index within array where new elements should be added * @count: variable tracking number of elements currently allocated @@ -179,18 +179,10 @@ int virDeleteElementsN(void *ptrptr, size_t size, siz= e_t at, size_t *countptr, * item 'newelem' into ptr[at], then store the address of * allocated memory in 'ptr' and the new size in 'count'. * - * VIR_INSERT_ELEMENT_COPY is identical, but doesn't clear out the - * original element to 0 on success, so there are two copies of the - * element. This is useful if the "element" is actually just a - * pointer to the real data, and you want to maintain a reference to - * it for use after the insert is completed; but if the "element" is - * an object that points to other allocated memory, having multiple - * copies can cause problems (e.g. double free). + * VIR_INSERT_ELEMENT_INPLACE is identical, but assumes any necessary + * memory re-allocation has already been done. * - * VIR_INSERT_ELEMENT_*INPLACE are identical, but assume any necessary - * memory re-allocation has already been done. - * - * VIR_INSERT_ELEMENT_* all need to send "1" as the "add" argument to + * Both functions need to send "1" as the "add" argument to * virInsertElementsN (which has the currently-unused capability of * inserting multiple items at once). We use this to our advantage by * replacing it with VIR_TYPECHECK(ptr, &newelem) so that we can be @@ -203,15 +195,9 @@ int virDeleteElementsN(void *ptrptr, size_t size, size= _t at, size_t *countptr, #define VIR_INSERT_ELEMENT(ptr, at, count, newelem) \ virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \ VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, f= alse) -#define VIR_INSERT_ELEMENT_COPY(ptr, at, count, newelem) \ - virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, = false) #define VIR_INSERT_ELEMENT_INPLACE(ptr, at, count, newelem) \ virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \ VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), true, t= rue) -#define VIR_INSERT_ELEMENT_COPY_INPLACE(ptr, at, count, newelem) \ - virInsertElementsN(&(ptr), sizeof(*(ptr)), at, &(count), \ - VIR_TYPEMATCH(ptr, &(newelem)), &(newelem), false, = true) =20 /** * VIR_APPEND_ELEMENT: --=20 2.31.1