[libbluray-devel] Make block input close function optional

Petri Hintukainen git at videolan.org
Tue May 19 12:20:42 CEST 2015


libudfread | branch: master | Petri Hintukainen <phintuka at gmail.com> | Tue May 19 12:51:20 2015 +0300| [ba7ef11e45753a91a89a43102d02449284584a76] | committer: Petri Hintukainen

Make block input close function optional

> http://git.videolan.org/gitweb.cgi/libudfread.git/?a=commit;h=ba7ef11e45753a91a89a43102d02449284584a76
---

 src/blockinput.h |    5 ++++-
 src/udfread.c    |    8 ++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/blockinput.h b/src/blockinput.h
index 8293b00..af8c41b 100644
--- a/src/blockinput.h
+++ b/src/blockinput.h
@@ -40,9 +40,12 @@ extern "C" {
 typedef struct udfread_block_input udfread_block_input;
 
 struct udfread_block_input {
+    /* Close input. Optional. */
     int      (*close) (udfread_block_input *);
+    /* Read block(s) from input. Mandatory. */
     int      (*read)  (udfread_block_input *, uint32_t lba, void *buf, uint32_t nblocks, int flags);
-    uint32_t (*size)  (udfread_block_input *);  /* size in blocks */
+    /* Input size in blocks. Optional. */
+    uint32_t (*size)  (udfread_block_input *);
 };
 
 
diff --git a/src/udfread.c b/src/udfread.c
index add9152..2a90ee8 100644
--- a/src/udfread.c
+++ b/src/udfread.c
@@ -1140,7 +1140,9 @@ int udfread_open(udfread *udf, const char *path)
 
     result = udfread_open_input(udf, input);
     if (result < 0) {
-        input->close(input);
+        if (input->close) {
+            input->close(input);
+        }
     }
 
     return result;
@@ -1150,7 +1152,9 @@ void udfread_close(udfread *udf)
 {
     if (udf) {
         if (udf->input) {
-            udf->input->close(udf->input);
+            if (udf->input->close) {
+                udf->input->close(udf->input);
+            }
             udf->input = NULL;
         }
 



More information about the libbluray-devel mailing list