[vlc-commits] os2: make high-memory safe
KO Myung-Hun
git at videolan.org
Sun Feb 23 15:46:46 CET 2014
vlc | branch: master | KO Myung-Hun <komh78 at gmail.com> | Sun Feb 23 19:38:10 2014 +0900| [8a62913aa35ed91c415c531ad7d5876e75b6dc1b] | committer: Rémi Denis-Courmont
os2: make high-memory safe
Some OS/2 APIs are not high-memory safe. So there are needs to use wrapper
functions to make them high-memory safe.
Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8a62913aa35ed91c415c531ad7d5876e75b6dc1b
---
include/vlc_common.h | 1 +
modules/access/vcd/cdrom.c | 56 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+)
diff --git a/include/vlc_common.h b/include/vlc_common.h
index 7e84f16..8b4b923 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -409,6 +409,7 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *, /* variable's object */
# define OS2EMX_PLAIN_CHAR
# define INCL_BASE
# define INCL_PM
+# include <os2safe.h>
# include <os2.h>
#endif
diff --git a/modules/access/vcd/cdrom.c b/modules/access/vcd/cdrom.c
index e536315..d55bef4 100644
--- a/modules/access/vcd/cdrom.c
+++ b/modules/access/vcd/cdrom.c
@@ -78,7 +78,63 @@
# include <sys/ioctl.h>
# include <linux/cdrom.h>
#elif defined( __OS2__ )
+# include <os2safe.h>
# include <os2.h>
+
+/*****************************************************************************
+ * vlc_DosDevIOCtl: high memory safe wrapper for DosDevIOCtl
+ *****************************************************************************
+ * Unfortunately, DosDevIOCtl() is not high memory safe API, and is not
+ * covered by os2safe.h. So define a wrapper function for it here.
+ *****************************************************************************/
+
+static APIRET vlc_DosDevIOCtl( HFILE hdevice, ULONG category, ULONG function,
+ PVOID pParams, ULONG cbParamLenMax,
+ PULONG pcbParamLen, PVOID pData,
+ ULONG cbDataLenMax, PULONG pcbDataLen )
+{
+ PVOID pParamsLow = NULL;
+ PVOID pDataLow = NULL;
+ ULONG cbParamLenLow;
+ ULONG cbDataLenLow;
+
+ APIRET rc;
+
+ rc = DosAllocMem( &pParamsLow, cbParamLenMax, fALLOC );
+ if( rc )
+ goto exit_free;
+
+ rc = DosAllocMem( &pDataLow, cbDataLenMax, fALLOC );
+ if( rc )
+ goto exit_free;
+
+ memcpy( pParamsLow, pParams, cbParamLenMax );
+ memcpy( pDataLow, pData, cbDataLenMax );
+
+ cbParamLenLow = *pcbParamLen;
+ cbDataLenLow = *pcbDataLen;
+
+ rc = DosDevIOCtl( hdevice, category, function, pParamsLow,
+ cbParamLenMax, &cbParamLenLow, pDataLow, cbDataLenMax,
+ &cbDataLenLow );
+
+ if( !rc )
+ {
+ memcpy( pParams, pParamsLow, cbParamLenMax );
+ memcpy( pData, pDataLow, cbDataLenMax );
+
+ *pcbParamLen = cbParamLenLow;
+ *pcbDataLen = cbDataLenLow;
+ }
+
+exit_free:
+ DosFreeMem( pParamsLow);
+ DosFreeMem( pDataLow);
+
+ return rc;
+}
+
+# define DosDevIOCtl vlc_DosDevIOCtl
#else
# error FIXME
#endif
More information about the vlc-commits
mailing list