[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2] libpoke: free the buffer of stream device only in read mo
From: |
Mohammad-Reza Nabipoor |
Subject: |
Re: [PATCH v2] libpoke: free the buffer of stream device only in read mode |
Date: |
Sun, 18 Oct 2020 19:42:41 +0330 |
Hi, Jose.
On Sun, Oct 18, 2020 at 05:57:39PM +0200, Jose E. Marchesi wrote:
>
> Hi Mohammad.
>
> > diff --git a/libpoke/ios-buffer.c b/libpoke/ios-buffer.c
> > index f3e1ad63..a2bdbb99 100644
> > --- a/libpoke/ios-buffer.c
> > +++ b/libpoke/ios-buffer.c
> > @@ -76,6 +76,9 @@ int
> > ios_buffer_free (struct ios_buffer *buffer)
> > {
> > struct ios_buffer_chunk *chunk, *chunk_next;
> > +
> > + assert(buffer != NULL);
> > +
> > for (int i = 0; i < IOB_BUCKET_COUNT; i++)
> > {
> > chunk = buffer->chunks[i];
>
> Even if we avoid calling ios_buffer_free in ios_dev_stream_close, I
> think it is always a good idea for the destructors to safely do nothing
> if NULL is passed. This is more according to the usual C semantics of
> `free'.
>
OK. I'll change the assertion to:
```c
if (buffer == NULL)
return 1;
```
Is this OK?
> On the other hand, do you have a savannah account?
Yes. mnabipoor.
Regards,
Mohammad-Reza