2 * common.cpp -- Blackmagic Design DeckLink common functions
3 * Copyright (C) 2012 Dan Dennedy <dan@dennedy.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with consumer library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 char* getCString( DLString aDLString )
27 char* CString = (char*) malloc( 64 );
28 CFStringGetCString( aDLString, CString, 64, kCFStringEncodingMacRoman );
32 void freeCString( char* aCString )
34 if ( aCString ) free( aCString );
37 void freeDLString( DLString aDLString )
39 if ( aDLString ) CFRelease( aDLString );
44 char* getCString( DLString aDLString )
49 int size = WideCharToMultiByte( CP_UTF8, 0, aDLString, -1, NULL, 0, NULL, NULL );
52 CString = new char[ size ];
53 size = WideCharToMultiByte( CP_UTF8, 0, aDLString, -1, CString, size, NULL, NULL );
64 void freeCString( char* aCString )
69 void freeDLString( DLString aDLString )
71 if ( aDLString ) free( (void*) aDLString );
76 char* getCString( DLString aDLString )
78 return aDLString? (char*) aDLString : NULL;
81 void freeCString( char* aCString )
85 void freeDLString( DLString aDLString )
87 if ( aDLString ) free( (void*) aDLString );