Commit 8a62913a authored by KO Myung-Hun's avatar KO Myung-Hun Committed by 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: default avatarRémi Denis-Courmont <remi@remlab.net>
parent bb3d20e7
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment