Commit 39bd5980 authored by Faustino Osuna's avatar Faustino Osuna

macosx/VLCKit: Load VLCLibrary when VLCKit is loaded. No longer need atexit(...

macosx/VLCKit: Load VLCLibrary when VLCKit is loaded.  No longer need atexit( ... ) to unload library, use __attribute__((destructor))__ instead.  Also make sure we don't autorelease the VLCLibrary (as the library's destructor will take care of that for us).
parent a0fd14f9
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
#import "VLCMediaList.h" #import "VLCMediaList.h"
#import "VLCMedia.h" #import "VLCMedia.h"
extern void * CreateSharedLibraryOnStartup( void ) __attribute__((constructor));
extern void * DestroySharedLibraryAtExit( void ) __attribute__((destructor));
@class VLCAudio; @class VLCAudio;
/** /**
......
...@@ -49,7 +49,20 @@ void __catch_exception( void * e, const char * function, const char * file, int ...@@ -49,7 +49,20 @@ void __catch_exception( void * e, const char * function, const char * file, int
} }
} }
static void * DestroySharedLibraryAtExit( void ) void * CreateSharedLibraryOnStartup( void )
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
/* This library is not loaded for no reason, so let's create
* a VLCLibrary instance. */
[VLCLibrary sharedLibrary];
[pool release];
return NULL;
}
void * DestroySharedLibraryAtExit( void )
{ {
/* Release the global object that may have been alloc-ed /* Release the global object that may have been alloc-ed
* in -[VLCLibrary init] */ * in -[VLCLibrary init] */
...@@ -66,11 +79,8 @@ static void * DestroySharedLibraryAtExit( void ) ...@@ -66,11 +79,8 @@ static void * DestroySharedLibraryAtExit( void )
{ {
/* Initialize a shared instance */ /* Initialize a shared instance */
sharedLibrary = [[self alloc] init]; sharedLibrary = [[self alloc] init];
/* Make sure, this will get released at some point */
atexit( (void *)DestroySharedLibraryAtExit );
} }
return [[sharedLibrary retain] autorelease]; return sharedLibrary;
} }
- (id)init - (id)init
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment