From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Tue, 02 Jul 2024 18:30:59 -0700 Received: from mail-yb1-f192.google.com ([209.85.219.192]) by mail.fairlystable.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sOopm-0007jb-QZ for bitcoindev@gnusha.org; Tue, 02 Jul 2024 18:30:59 -0700 Received: by mail-yb1-f192.google.com with SMTP id 3f1490d57ef6-e035f7b5976sf270661276.0 for ; Tue, 02 Jul 2024 18:30:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1719970252; x=1720575052; darn=gnusha.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-sender:mime-version :subject:references:in-reply-to:message-id:to:from:date:sender:from :to:cc:subject:date:message-id:reply-to; bh=ENJq+PIOObjJOFd6YWMv22Wq6XZLGTUgViJlswpymnY=; b=xh4TfisqXYYDR+r5fLc7gPt9P5LOFedH+PwRjT/sW6PWmlIR4aF95gIT5JtDlBNUSF g1QY3UCApvnnDvwtAcXap3seNBX5b3cgAm1Feer7AI1mk0q1VoXrueWH5Vy7pZZS7pP8 to8RUVOgJ1U656FS9jY+RIR0v8oS8Imkp3xbIyt/Wm6r3y15RJV+7EPUiGfjBBpANXjM 20u9CVCuOZF/JKgNG+dmykGgrJA2PQb7huDUbYgk96+5qf5GA9U5WS8FwmM5L1S+/EOV A3+RFYAqM9twG0xCaEygpDYEJKaTVuhn1zHj8rAAg47pKpoQ/Vm1n1ohL5Qtsk4I5Qa/ rVXg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719970252; x=1720575052; darn=gnusha.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-sender:mime-version :subject:references:in-reply-to:message-id:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=ENJq+PIOObjJOFd6YWMv22Wq6XZLGTUgViJlswpymnY=; b=gQW7ak41AboQl9Q2U3dmbp8FhoZ02Ttk/SFOpGV1r0JDuqwWl+D6ZAR0/3VeQvFoF4 u7NXZ1bjDz31gK6bDDBg30WZsmeVeXf5E/KQ5TZOG5wj2HSbUv2NJT/6yZvHfjIz0NG/ 1e9khVDw3U5SMYwjUa62ccLFa+IyHWyYINBJdv+33+Z2eKDOxwGjAkBmuaNWY2oIL5j6 m9281Sm6uW10QLEWfA0ZVAzLEdxNfPOZdDk9x2MUPKxhCGxkBjvAjeqJp4rXesOuKG/i LxIau2npU6MqsKE2ggGrJcsMZ4i9OJULu7qEW+bNB6MSLU5ZfFgM/tOGEfHFxcMEeScH K3dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719970252; x=1720575052; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-sender:mime-version :subject:references:in-reply-to:message-id:to:from:date:x-beenthere :x-gm-message-state:sender:from:to:cc:subject:date:message-id :reply-to; bh=ENJq+PIOObjJOFd6YWMv22Wq6XZLGTUgViJlswpymnY=; b=SYy7FUsDgU8LyvWgdlN5y4W0+04trfiLhJgIunH4UxHbs6gobOnI1x+uQPHF7GRyzL T4LjsPz4qXc9aFk5yQS5dBVfIXmR2ja9zt2Xkj5r906qgnDA5qAf8sE1v0xQlVjR3uKO ogN0IgSUzyrfupG6cFWejvyG9kSq3B6oJR5ryhXTLvaQFO1HpTXMxkZLY4qaSU2jUD9Z t6TrqCLljttlO1Ao/DN9O8AGzPYuy1mfRtpoyJ+ZUoYq8lzaJFBJmP7OaJKWqpfPqvhF RMQZx/gh1Tzn+IeO/6lUDoViYNn1ssgV7yh3hcce0uWPcgJljVTXk6T4BUGnJM8ASDiY Rahg== Sender: bitcoindev@googlegroups.com X-Forwarded-Encrypted: i=1; AJvYcCVIIx5UCB3HjYhw92RRp3n6aNYy7XxyjMp3sQdHbvUwASo5Vf+BJt4Qk64KkumhWhX2RFPwAYOzvHG3jJlFK3JfLbCrAkQ= X-Gm-Message-State: AOJu0YxbImI5pcU2HvhPJGmdX/M6uHa7EzP5j1XJFh2d5w2LU0aX1bNP SuLT7/79ZOZ6Hwgw9/BOoSdlpVBJaLUz7yio0zsJEw2W66AjVcPF X-Google-Smtp-Source: AGHT+IGpL2yPzioFGWrI/3JXXd5bxgUmj1+5zOf6XvRrMx8tXZKh8F7cWFwQA5XdaKD+BcI3+p/0vg== X-Received: by 2002:a25:9090:0:b0:e03:a504:5c92 with SMTP id 3f1490d57ef6-e03ad9692c5mr137563276.30.1719970252055; Tue, 02 Jul 2024 18:30:52 -0700 (PDT) X-BeenThere: bitcoindev@googlegroups.com Received: by 2002:a05:6902:722:b0:dfa:77ba:dc1f with SMTP id 3f1490d57ef6-e0356274b10ls7600763276.2.-pod-prod-06-us; Tue, 02 Jul 2024 18:30:50 -0700 (PDT) X-Received: by 2002:a05:6902:2b89:b0:dff:83e:b259 with SMTP id 3f1490d57ef6-e036eb4a8cemr1100341276.6.1719970250443; Tue, 02 Jul 2024 18:30:50 -0700 (PDT) Received: by 2002:a05:690c:4289:b0:63b:c3b0:e1c with SMTP id 00721157ae682-6514011671ams7b3; Tue, 2 Jul 2024 18:07:10 -0700 (PDT) X-Received: by 2002:a05:6902:298e:b0:e03:54e2:4ca2 with SMTP id 3f1490d57ef6-e036eb1b316mr115143276.4.1719968827937; Tue, 02 Jul 2024 18:07:07 -0700 (PDT) Date: Tue, 2 Jul 2024 18:07:07 -0700 (PDT) From: Larry Ruane To: Bitcoin Development Mailing List Message-Id: In-Reply-To: <301c64c7-0f0f-476a-90c4-913659477276n@googlegroups.com> References: <72e83c31-408f-4c13-bff5-bf0789302e23n@googlegroups.com> <5b0331a5-4e94-465d-a51d-02166e2c1937n@googlegroups.com> <9a4c4151-36ed-425a-a535-aa2837919a04n@googlegroups.com> <3f0064f9-54bd-46a7-9d9a-c54b99aca7b2n@googlegroups.com> <26b7321b-cc64-44b9-bc95-a4d8feb701e5n@googlegroups.com> <607a2233-ac12-4a80-ae4a-08341b3549b3n@googlegroups.com> <3dceca4d-03a8-44f3-be64-396702247fadn@googlegroups.com> <301c64c7-0f0f-476a-90c4-913659477276n@googlegroups.com> Subject: Re: [bitcoindev] Re: Great Consensus Cleanup Revival MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_27134_840701207.1719968827654" X-Original-Sender: LarryRuane@gmail.com Precedence: list Mailing-list: list bitcoindev@googlegroups.com; contact bitcoindev+owners@googlegroups.com List-ID: X-Google-Group-Id: 786775582512 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-Spam-Score: -0.5 (/) ------=_Part_27134_840701207.1719968827654 Content-Type: multipart/alternative; boundary="----=_Part_27135_537405036.1719968827654" ------=_Part_27135_537405036.1719968827654 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Monday, July 1, 2024 at 11:03:33=E2=80=AFPM UTC-6 Antoine Riard wrote: Here a snippet example of linked list code checking the pointer=20 (`*begin_list`) is non null before the comparison operation to find the=20 target element list. ``` pointer_t ft_list_find(pointer_t **start_list, void *data_ref, int=20 (*cmp)()) { while (*start_list) { if (cmp((*start_list)->data, data_ref) =3D=3D 0) return (*start_list); *start_list =3D (*start_list)->next; } return (0); } ``` I assume this function lets you search for an element starting in the=20 middle of a single-linked list (the middle because you could call=20 `ft_list_find(&p-next, data_ref)` where `p` points to any element in the=20 middle of the list, including possibly the last item in the list, in which= =20 case the loop body wouldn't run). If so, I don't think this does what's=20 intended. This actually unlinks (and memory-leaks) elements up to where the= =20 match is found. I think you want to advance `start_list` this way (I didn't= =20 test this): ``` start_list =3D &(*start_list)->next; ``` Larry --=20 You received this message because you are subscribed to the Google Groups "= Bitcoin Development Mailing List" group. To unsubscribe from this group and stop receiving emails from it, send an e= mail to bitcoindev+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/= bitcoindev/e2c61ee5-68c4-461e-a132-bb86a4c3e2ccn%40googlegroups.com. ------=_Part_27135_537405036.1719968827654 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Monday, July 1, 2024 at 11:03:33=E2=80=AFPM UTC-6= Antoine Riard wrote:
<= br />Here a snippet example of linked list code checking the pointer (`*beg= in_list`) is non null before the comparison operation to find the target el= ement list.

```
pointer_t =C2=A0 =C2=A0 =C2=A0 ft_list_find= (pointer_t **start_list, void *data_ref, int (*cmp)())
{
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 while (*start_list)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 {=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (cmp((*sta= rt_list)->data, data_ref) =3D=3D 0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return (*start_list);<= br />=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *start_list = =3D (*start_list)->next;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 return (0);
}
```

I assume this function lets you search for an element st= arting in the middle of a single-linked list (the middle because you could = call `ft_list_find(&p-next, data_ref)` where `p` points to any element = in the middle of the list, including possibly the last item in the list, in= which case the loop body wouldn't run). If so, I don't think this does wha= t's intended. This actually unlinks (and memory-leaks) elements up to where= the match is found. I think you want to advance `start_list` this way (I d= idn't test this):

```
=C2=A0 =C2=A0 st= art_list =3D &(*start_list)->next;
```

Larry

--
You received this message because you are subscribed to the Google Groups &= quot;Bitcoin Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to bitcoind= ev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg= id/bitcoindev/e2c61ee5-68c4-461e-a132-bb86a4c3e2ccn%40googlegroups.com.=
------=_Part_27135_537405036.1719968827654-- ------=_Part_27134_840701207.1719968827654--