From 376154353d54add4b9f7f3bf0ba934bf03e2de4b Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Sat, 16 Jun 2012 12:53:43 -0700 Subject: [PATCH] fix BSTR string conversion under Windows --- src/modules/decklink/common.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/modules/decklink/common.cpp b/src/modules/decklink/common.cpp index 84ef72fb..83f5e531 100644 --- a/src/modules/decklink/common.cpp +++ b/src/modules/decklink/common.cpp @@ -39,6 +39,38 @@ void freeDLString( DLString aDLString ) if ( aDLString ) CFRelease( aDLString ); } +#elif defined(WIN32) + +char* getCString( DLString aDLString ) +{ + char* CString = NULL; + if ( aDLString ) + { + int size = WideCharToMultiByte( CP_UTF8, 0, aDLString, -1, NULL, 0, NULL, NULL ); + if (size) + { + CString = new char[ size ]; + size = WideCharToMultiByte( CP_UTF8, 0, aDLString, -1, CString, size, NULL, NULL ); + if ( !size ) + { + delete[] CString; + CString = NULL; + } + } + } + return CString; +} + +void freeCString( char* aCString ) +{ + delete[] aCString; +} + +void freeDLString( DLString aDLString ) +{ + if ( aDLString ) free( (void*) aDLString ); +} + #else char* getCString( DLString aDLString ) -- 2.39.2