[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: |
Jose E. Marchesi |
Subject: |
Re: [PATCH v2] libpoke: free the buffer of stream device only in read mode |
Date: |
Sun, 18 Oct 2020 17:57:39 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
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'.
On the other hand, do you have a savannah account?