[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3] libpoke: free the buffer of stream device only in read mode
From: |
Mohammad-Reza Nabipoor |
Subject: |
[PATCH v3] libpoke: free the buffer of stream device only in read mode |
Date: |
Sun, 18 Oct 2020 22:51:09 +0330 |
2020-10-18 Mohammad-Reza Nabipoor <m.nabipoor@yahoo.com>
* libpoke/ios-dev-stream.c (ios_dev_stream_close): Free buffer only
in read mode.
* libpoke/ios-buffer.h (ios_buffer_free): Change return type to void.
* libpoke/ios-buffer.c (ios_buffer_free): Handle buffer == NULL.
---
ChangeLog | 7 +++++++
libpoke/ios-buffer.c | 8 ++++++--
libpoke/ios-buffer.h | 3 ++-
libpoke/ios-dev-stream.c | 3 ++-
4 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e481d90b..839ecd76 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2020-10-18 Mohammad-Reza Nabipoor <m.nabipoor@yahoo.com>
+
+ * libpoke/ios-dev-stream.c (ios_dev_stream_close): Free buffer only
+ in read mode.
+ * libpoke/ios-buffer.h (ios_buffer_free): Change return type to void.
+ * libpoke/ios-buffer.c (ios_buffer_free): Handle buffer == NULL.
+
2020-10-12 Egeyar Bagcioglu <egeyar@gmail.com>
* libpoke/Makefile.am (libpoke_la_SOURCES): Add ios-buffer.h,
diff --git a/libpoke/ios-buffer.c b/libpoke/ios-buffer.c
index f3e1ad63..62906108 100644
--- a/libpoke/ios-buffer.c
+++ b/libpoke/ios-buffer.c
@@ -72,10 +72,14 @@ ios_buffer_init ()
return bio;
}
-int
+void
ios_buffer_free (struct ios_buffer *buffer)
{
struct ios_buffer_chunk *chunk, *chunk_next;
+
+ if (buffer == NULL)
+ return;
+
for (int i = 0; i < IOB_BUCKET_COUNT; i++)
{
chunk = buffer->chunks[i];
@@ -88,7 +92,7 @@ ios_buffer_free (struct ios_buffer *buffer)
}
free (buffer);
- return 1;
+ return;
}
struct ios_buffer_chunk*
diff --git a/libpoke/ios-buffer.h b/libpoke/ios-buffer.h
index 838999d6..03851548 100644
--- a/libpoke/ios-buffer.h
+++ b/libpoke/ios-buffer.h
@@ -20,7 +20,8 @@ struct ios_buffer;
struct ios_buffer * ios_buffer_init ();
-int ios_buffer_free (struct ios_buffer *buffer);
+void
+ios_buffer_free (struct ios_buffer *buffer);
ios_dev_off
ios_buffer_get_begin_offset (struct ios_buffer *buffer);
diff --git a/libpoke/ios-dev-stream.c b/libpoke/ios-dev-stream.c
index 1258bfe5..0832011c 100644
--- a/libpoke/ios-dev-stream.c
+++ b/libpoke/ios-dev-stream.c
@@ -118,7 +118,8 @@ ios_dev_stream_close (void *iod)
{
struct ios_dev_stream *sio = iod;
- ios_buffer_free (sio->buffer);
+ if (sio->flags & IOS_F_READ)
+ ios_buffer_free (sio->buffer);
free (sio);
return 1;
--
2.28.0
- [PATCH v3] libpoke: free the buffer of stream device only in read mode,
Mohammad-Reza Nabipoor <=
- Re: [PATCH v3] libpoke: free the buffer of stream device only in read mode, Jose E. Marchesi, 2020/10/18
- Re: [PATCH v3] libpoke: free the buffer of stream device only in read mode, Mohammad-Reza Nabipoor, 2020/10/18
- Re: [PATCH v3] libpoke: free the buffer of stream device only in read mode, Jose E. Marchesi, 2020/10/18
- Re: [PATCH v3] libpoke: free the buffer of stream device only in read mode, Egeyar Bagcioglu, 2020/10/19
- Re: [PATCH v3] libpoke: free the buffer of stream device only in read mode, Mohammad-Reza Nabipoor, 2020/10/19
- Re: [PATCH v3] libpoke: free the buffer of stream device only in read mode, Jose E. Marchesi, 2020/10/19
- Re: [PATCH v3] libpoke: free the buffer of stream device only in read mode, Mohammad-Reza Nabipoor, 2020/10/19
- Re: [PATCH v3] libpoke: free the buffer of stream device only in read mode, egeyar, 2020/10/19
Re: [PATCH v3] libpoke: free the buffer of stream device only in read mode, Mohammad-Reza Nabipoor, 2020/10/19