[vlc-devel] [PATCH 6/7] darwin/dirs: Use FromCFString

Marvin Scholz epirat07 at gmail.com
Mon Oct 8 10:56:02 CEST 2018


---
 src/darwin/dirs.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/src/darwin/dirs.c b/src/darwin/dirs.c
index de95ef31dc..6c4c538f6e 100644
--- a/src/darwin/dirs.c
+++ b/src/darwin/dirs.c
@@ -28,6 +28,7 @@
 #endif
 
 #include <vlc_common.h>
+#include <vlc_charset.h>
 #include "../libvlc.h"
 
 #include <libgen.h>
@@ -175,18 +176,8 @@ static char *getAppDependentDir(vlc_userdir_t type)
     CFBundleRef mainBundle = CFBundleGetMainBundle();
     if (mainBundle) {
         CFStringRef identifierAsNS = CFBundleGetIdentifier(mainBundle);
-        if (identifierAsNS) {
-            CFIndex len = CFStringGetLength(identifierAsNS);
-            CFIndex size = CFStringGetMaximumSizeForEncoding(len, kCFStringEncodingUTF8);
-            char *identifier = calloc(len + 1, sizeof(char));
-            if (identifier != NULL) {
-                Boolean ret = CFStringGetCString(identifierAsNS, identifier, size, kCFStringEncodingUTF8);
-                if (ret)
-                    name = identifier;
-                else
-                    free(identifier);
-            }
-        }
+        if (identifierAsNS)
+            name = FromCFString(identifierAsNS, kCFStringEncodingUTF8);
     }
 
     char *psz_parent = config_GetHomeDir ();
-- 
2.19.1



More information about the vlc-devel mailing list