Differences From Artifact [c230c7ec3d]:
- File src/OFPlugin.m — part of check-in [ddcfab2b93] at 2012-07-20 14:17:30 on branch trunk — Blocks need to be copied, not retained. (user: js, size: 2077) [annotate] [blame] [check-ins using]
To Artifact [a25e85e2c5]:
- File
src/OFPlugin.m
— part of check-in
[1255f3a11a]
at
2012-08-10 20:08:24
on branch trunk
— Directly use the runtime's autorelease pools.
This greatly improves performance, as it gets rid of the overhead of
OFAutoreleasePool. (user: js, size: 2061) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
21 22 23 24 25 26 27 | #ifndef _WIN32 #include <dlfcn.h> #endif #import "OFPlugin.h" #import "OFString.h" | < > > | < | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #ifndef _WIN32 #include <dlfcn.h> #endif #import "OFPlugin.h" #import "OFString.h" #import "OFInitializationFailedException.h" #import "OFNotImplementedException.h" #import "autorelease.h" #ifdef _WIN32 # define dlopen(file, mode) LoadLibrary(file) # define dlsym(handle, symbol) GetProcAddress(handle, symbol) # define dlclose(handle) FreeLibrary(handle) #endif @implementation OFPlugin + (id)pluginFromFile: (OFString*)path { void *pool = objc_autoreleasePoolPush(); OFMutableString *file; of_plugin_handle_t handle; OFPlugin *(*initPlugin)(void); OFPlugin *plugin; file = [OFMutableString stringWithString: path]; [file appendString: @PLUGIN_SUFFIX]; if ((handle = dlopen([file cStringWithEncoding: OF_STRING_ENCODING_NATIVE], RTLD_LAZY)) == NULL) @throw [OFInitializationFailedException exceptionWithClass: self]; objc_autoreleasePoolPop(pool); *(void**)&initPlugin = dlsym(handle, "init_plugin"); if (initPlugin == NULL || (plugin = initPlugin()) == nil) { dlclose(handle); @throw [OFInitializationFailedException exceptionWithClass: self]; } |
︙ | ︙ |