ObjFW  Check-in [066bf9c8c3]

Overview
Comment:Remove stuff forgotten after moving code in OFPlugin.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 066bf9c8c3c9043aadc5a2ada2910cd7f303762c5f10ad5adf94c3830aacd6c2
User & Date: js on 2009-04-19 20:29:58
Other Links: manifest | tags
Context
2009-04-19
20:34
Use isa instead of [self class]. check-in: 139591afe1 user: js tags: trunk
20:29
Remove stuff forgotten after moving code in OFPlugin. check-in: 066bf9c8c3 user: js tags: trunk
20:22
Remove useless definitions. check-in: a756d3f511 user: js tags: trunk
Changes

Modified src/OFPlugin.m from [ee4d5662a9] to [b72d21c5c5].

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
65
66
67
68
+ pluginFromFile: (const char*)path
{
	char *file;
	size_t pathlen, suffixlen;
	void *handle;
	OFPlugin *(*init_plugin)();
	OFPlugin *plugin;
	Class c;

	if ((self = [super init])) {
		pathlen = strlen(path);
		suffixlen = strlen(PLUGIN_SUFFIX);

		if ((file = malloc(pathlen + suffixlen + 1)) == NULL) {
			c = [self class];
			[super free];
			@throw [OFNoMemException newWithClass: c
						      andSize: pathlen +
							       suffixlen + 1];
		}
		memcpy(file, path, pathlen);
		memcpy(file + pathlen, PLUGIN_SUFFIX, suffixlen);
		file[pathlen + suffixlen] = 0;

		if ((handle = dlopen(file, RTLD_NOW)) == NULL) {
			free(file);
			c = [self class];
			[super free];
			@throw [OFInitializationFailedException
			    newWithClass: c];
		}
		free(file);

		if ((init_plugin = dlsym(handle, "init_plugin")) == NULL ||
		    (plugin = init_plugin()) == nil) {
			dlclose(handle);
			c = [self class];
			[super free];
			@throw [OFInitializationFailedException
			    newWithClass: c];
		}

		plugin->handle = handle;
		return plugin;
	}

	return self;







<






<
<
|









<
<

|






<
<

|







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
+ pluginFromFile: (const char*)path
{
	char *file;
	size_t pathlen, suffixlen;
	void *handle;
	OFPlugin *(*init_plugin)();
	OFPlugin *plugin;


	if ((self = [super init])) {
		pathlen = strlen(path);
		suffixlen = strlen(PLUGIN_SUFFIX);

		if ((file = malloc(pathlen + suffixlen + 1)) == NULL) {


			@throw [OFNoMemException newWithClass: self
						      andSize: pathlen +
							       suffixlen + 1];
		}
		memcpy(file, path, pathlen);
		memcpy(file + pathlen, PLUGIN_SUFFIX, suffixlen);
		file[pathlen + suffixlen] = 0;

		if ((handle = dlopen(file, RTLD_NOW)) == NULL) {
			free(file);


			@throw [OFInitializationFailedException
			    newWithClass: self];
		}
		free(file);

		if ((init_plugin = dlsym(handle, "init_plugin")) == NULL ||
		    (plugin = init_plugin()) == nil) {
			dlclose(handle);


			@throw [OFInitializationFailedException
			    newWithClass: self];
		}

		plugin->handle = handle;
		return plugin;
	}

	return self;