]> git.sesse.net Git - vlc/blobdiff - src/misc/darwin_specific.c
vcdx: Fix memleaks.
[vlc] / src / misc / darwin_specific.c
index c45cc437a919c9f72779926e4f310a01c4dae4b4..6e68ee1241dea61c9f0cc69414c11b3f5d89529d 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
 #include "../libvlc.h"
 #include <dirent.h>                                                /* *dir() */
 
 #ifdef HAVE_LOCALE_H
 #   include <locale.h>
 #endif
+#ifdef HAVE_MACH_O_DYLD_H
+#   include <mach-o/dyld.h>
+#endif
+
+#ifndef MAXPATHLEN
+# define MAXPATHLEN 1024
+#endif
 
 /* CFLocaleCopyAvailableLocaleIdentifiers is present only on post-10.4 */
 extern CFArrayRef CFLocaleCopyAvailableLocaleIdentifiers(void) __attribute__((weak_import));
@@ -63,23 +74,25 @@ static CFArrayRef copy_all_locale_indentifiers(void)
 /*****************************************************************************
  * system_Init: fill in program path & retrieve language
  *****************************************************************************/
-void system_Init( libvlc_int_t *p_this, int *pi_argc, char *ppsz_argv[] )
+void system_Init( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] )
 {
+    VLC_UNUSED(p_this);
     char i_dummy;
     char *p_char = NULL;
     char *p_oldchar = &i_dummy;
-    int i;
+    unsigned int i;
+    (void)pi_argc;
 
     /* Get the full program path and name */
 
     /* First try to see if we are linked to the framework */
     for (i = 0; i < _dyld_image_count(); i++)
     {
-        char * psz_img_name = _dyld_get_image_name(i);
-        /* Check for "VLCKit.framework/Versions/Current/VLC",
-         * as well as "VLCKit.framework/Versions/A/VLC" and
-         * "VLC.framework/Versions/B/VLC" */
-        if( p_char = strstr( psz_img_name, "VLCKit.framework/Versions/" ))
+        const char * psz_img_name = _dyld_get_image_name(i);
+        /* Check for "VLCKit.framework/Versions/Current/VLCKit",
+         * as well as "VLCKit.framework/Versions/A/VLCKit" and
+         * "VLC.framework/Versions/B/VLCKit" */
+        if( (p_char = strstr( psz_img_name, "VLCKit.framework/Versions/" )) )
         {
             /* Look for the next forward slash */
             p_char += 26; /* p_char += strlen(" VLCKit.framework/Versions/" ) */
@@ -87,7 +100,7 @@ void system_Init( libvlc_int_t *p_this, int *pi_argc, char *ppsz_argv[] )
                 p_char++;
             
             /* If the string ends with VLC then we've found a winner */
-            if ( !strcmp( p_char, "/VLC" ) )
+            if ( !strcmp( p_char, "/VLCKit" ) )
             {
                 p_char = strdup( psz_img_name );
                 break;
@@ -97,6 +110,13 @@ void system_Init( libvlc_int_t *p_this, int *pi_argc, char *ppsz_argv[] )
         }
     }
 
+    if( !p_char )
+    {
+        char path[MAXPATHLEN+1];
+        uint32_t path_len = MAXPATHLEN;
+        if ( !_NSGetExecutablePath(path, &path_len) )
+            p_char = strdup(path);
+    }
     if( !p_char )
     {
         /* We are not linked to the VLC.framework, return the executable path */
@@ -124,7 +144,7 @@ void system_Init( libvlc_int_t *p_this, int *pi_argc, char *ppsz_argv[] )
         /*
            Retrieve the preferred language as chosen in  System Preferences.app
            (note that CFLocaleCopyCurrent() is not used because it returns the
-            prefered locale not language)
+            preferred locale not language)
         */
         CFArrayRef all_locales, preferred_locales;
         char psz_locale[50];
@@ -148,17 +168,16 @@ void system_Init( libvlc_int_t *p_this, int *pi_argc, char *ppsz_argv[] )
         }
         CFRelease( all_locales );
     }
-
-    vlc_mutex_init( p_this, &vlc_global()->iconv_lock );
-    vlc_global()->iconv_macosx = vlc_iconv_open( "UTF-8", "UTF-8-MAC" );
 }
 
 /*****************************************************************************
  * system_Configure: check for system specific configuration options.
  *****************************************************************************/
-void system_Configure( libvlc_int_t *p_this, int *pi_argc, char *ppsz_argv[] )
+void system_Configure( libvlc_int_t *p_this, int *pi_argc, const char *ppsz_argv[] )
 {
-
+    (void)p_this;
+    (void)pi_argc;
+    (void)ppsz_argv;
 }
 
 /*****************************************************************************
@@ -166,10 +185,7 @@ void system_Configure( libvlc_int_t *p_this, int *pi_argc, char *ppsz_argv[] )
  *****************************************************************************/
 void system_End( libvlc_int_t *p_this )
 {
+    (void)p_this;
     free( vlc_global()->psz_vlcpath );
-
-    if ( vlc_global()->iconv_macosx != (vlc_iconv_t)-1 )
-        vlc_iconv_close( vlc_global()->iconv_macosx );
-    vlc_mutex_destroy( &vlc_global()->iconv_lock );
 }