[libbluray-devel] file: replace macros with inline functions

hpi1 git at videolan.org
Fri Aug 19 17:36:18 CEST 2016


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Aug 15 13:15:45 2016 +0300| [bd96f3169d120cb6124f019b6b15be27e1bb16fd] | committer: hpi1

file: replace macros with inline functions

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

 src/file/file.h | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/file/file.h b/src/file/file.h
index 54b053e..afa5fa7 100644
--- a/src/file/file.h
+++ b/src/file/file.h
@@ -26,6 +26,7 @@
 #include "util/attributes.h"
 
 #include <stdint.h>
+#include <stddef.h>
 
 #ifdef _WIN32
 # define DIR_SEP "\\"
@@ -39,12 +40,29 @@
  * file access
  */
 
-#define file_close(X)    X->close(X)
-#define file_seek(X,Y,Z) X->seek(X,Y,Z)
-#define file_tell(X)     X->tell(X)
 //#define file_eof(X) X->eof(X)
-#define file_read(X,Y,Z) (size_t)X->read(X,Y,Z)
 //#define file_write(X,Y,Z) (size_t)X->write(X,Y,Z)
+
+static inline void file_close(BD_FILE_H *fp)
+{
+    fp->close(fp);
+}
+
+static inline int64_t file_tell(BD_FILE_H *fp)
+{
+    return fp->tell(fp);
+}
+
+static inline BD_USED int64_t file_seek(BD_FILE_H *fp, int64_t offset, int32_t origin)
+{
+    return fp->seek(fp, offset, origin);
+}
+
+static inline BD_USED size_t file_read(BD_FILE_H *fp, uint8_t *buf, size_t size)
+{
+    return (size_t)fp->read(fp, buf, (int64_t)size);
+}
+
 BD_PRIVATE int64_t file_size(BD_FILE_H *fp);
 
 BD_PRIVATE extern BD_FILE_H* (*file_open)(const char* filename, const char *mode);



More information about the libbluray-devel mailing list