I think you could make an argument that Core Foundation is a C API so malloc/free make sense, but I agree, using that or new/delete here is probably not the best choice.

One option is to use [CFStringGetCStringPtr](https://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFStringRef/Reference/reference.html#//apple_ref/c/func/CFStringGetCStringPtr) which will accomplish the same thing while not requiring us to pass it a buffer. Docs stress that this may fail and was should fall back to `CFStringGetCString` anyway so switching to the pointer version doesn't really resolve anything.

Looks like the best course is to define `buff` like this:

`char buff[length];`

Then pass that into `CFStringGetCString` by reference. Both [GCC](http://gcc.gnu.org/onlinedocs/gcc/Variable-Length.html) and [Clang](http://clang.llvm.org/compatibility.html) (search for "Variable-length arrays" on the Clang link) support variable-length arrays so this should should be fine on all supported Mac OS versions.

I don't think it's possible to use `std::string` from the get-go as `buff` gets passed into `CGStringGetCString` which is expecting a `char*`.