public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
From: Larry Ruane <larryruane@gmail•com>
To: Bitcoin Development Mailing List <bitcoindev@googlegroups.com>
Subject: Re: [bitcoindev] Re: Great Consensus Cleanup Revival
Date: Tue, 2 Jul 2024 18:07:07 -0700 (PDT)	[thread overview]
Message-ID: <e2c61ee5-68c4-461e-a132-bb86a4c3e2ccn@googlegroups.com> (raw)
In-Reply-To: <301c64c7-0f0f-476a-90c4-913659477276n@googlegroups.com>


[-- Attachment #1.1: Type: text/plain, Size: 1566 bytes --]

On Monday, July 1, 2024 at 11:03:33 PM UTC-6 Antoine Riard wrote:


Here a snippet example of linked list code checking the pointer 
(`*begin_list`) is non null before the comparison operation to find the 
target element list.

```
pointer_t       ft_list_find(pointer_t **start_list, void *data_ref, int 
(*cmp)())
{
        while (*start_list)
        {
                if (cmp((*start_list)->data, data_ref) == 0)
                        return (*start_list);
                *start_list = (*start_list)->next;
        }
        return (0);
}
```


I assume this function lets you search for an element starting 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 what'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 didn't 
test this):

```
    start_list = &(*start_list)->next;
```

Larry

-- 
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 email 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.

[-- Attachment #1.2: Type: text/html, Size: 2175 bytes --]

  reply	other threads:[~2024-07-03  1:30 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-24 18:10 [bitcoindev] " 'Antoine Poinsot' via Bitcoin Development Mailing List
2024-03-26 19:11 ` [bitcoindev] " Antoine Riard
2024-03-27 10:35   ` 'Antoine Poinsot' via Bitcoin Development Mailing List
2024-03-27 18:57     ` Antoine Riard
2024-04-18  0:46     ` Mark F
2024-04-18 10:04       ` 'Antoine Poinsot' via Bitcoin Development Mailing List
2024-04-25  6:08         ` Antoine Riard
2024-04-30 22:20           ` Mark F
2024-05-06  1:10             ` Antoine Riard
2024-06-17 22:15 ` Eric Voskuil
2024-06-18  8:13   ` 'Antoine Poinsot' via Bitcoin Development Mailing List
2024-06-18 13:02     ` Eric Voskuil
2024-06-21 13:09       ` 'Antoine Poinsot' via Bitcoin Development Mailing List
2024-06-24  0:35         ` Eric Voskuil
2024-06-27  9:35           ` 'Antoine Poinsot' via Bitcoin Development Mailing List
2024-06-28 17:14             ` Eric Voskuil
2024-06-29  1:06               ` Antoine Riard
2024-06-29  1:31                 ` Eric Voskuil
2024-06-29  1:53                   ` Antoine Riard
2024-06-29 20:29                     ` Eric Voskuil
2024-06-29 20:40                       ` Eric Voskuil
2024-07-02  2:36                         ` Antoine Riard
2024-07-03  1:07                           ` Larry Ruane [this message]
2024-07-03  1:13                           ` Eric Voskuil
2024-07-02 10:23               ` 'Antoine Poinsot' via Bitcoin Development Mailing List
2024-07-02 15:57                 ` Eric Voskuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e2c61ee5-68c4-461e-a132-bb86a4c3e2ccn@googlegroups.com \
    --to=larryruane@gmail$(echo .)com \
    --cc=bitcoindev@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox