diff --git a/plugins/decklink/mac/platform.cpp b/plugins/decklink/mac/platform.cpp index 02e8a59ba..21ca4ec98 100644 --- a/plugins/decklink/mac/platform.cpp +++ b/plugins/decklink/mac/platform.cpp @@ -1,22 +1,17 @@ #include "../platform.hpp" +#include bool DeckLinkStringToStdString(decklink_string_t input, std::string& output) { const CFStringRef string = static_cast(input); - const CFIndex length = CFStringGetLength(string); - const CFIndex maxLength = CFStringGetMaximumSizeForEncoding(length, - kCFStringEncodingASCII) + 1; - char * const buffer = new char[maxLength]; + char *buffer = cfstr_copy_cstr(string, kCFStringEncodingASCII); - const bool result = CFStringGetCString(string, buffer, maxLength, - kCFStringEncodingASCII); - - if (result) + if (buffer) output = std::string(buffer); - delete[] buffer; + bfree(buffer); CFRelease(string); - return result; + return (buffer != NULL); }