ObjFW  Check-in [03618ea87b]

Overview
Comment:Also release the pools when we release the pool list.
We need to do that manually as we disabled retain / release for the
list.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 03618ea87b2b32d00dd34185fd265a8a285af5438a8197d0fc8f85db5c15d095
User & Date: js on 2009-01-07 17:10:18
Other Links: manifest | tags
Context
2009-01-07
20:49
For some reason, proper overflow checks were only in OFBigArray. check-in: f724e6d794 user: js tags: trunk
17:10
Also release the pools when we release the pool list.
We need to do that manually as we disabled retain / release for the
list.
check-in: 03618ea87b user: js tags: trunk
2009-01-06
22:38
Use OFList and OFArray in OFAutoreleasePool.
This reduces code duplication and looks far better.
check-in: dfc10dbeb8 user: js tags: trunk
Changes

Modified src/OFAutoreleasePool.m from [8a91012795] to [d3843af4f8].

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
#define get_tls(t) TlsGetValue(t)
#define set_tls(t, v) TlsSetValue(t, v)
static DWORD pool_list_key;
#endif

#ifndef _WIN32
static void



release_obj(void *obj)
{






	[(OFObject*)obj release];
}
#endif

@implementation OFAutoreleasePool
+ (void)initialize
{
#ifndef _WIN32
	if (pthread_key_create(&pool_list_key, release_obj))
		@throw [OFInitializationFailedException newWithClass: self];
#else
	/* FIXME: Free stuff when thread is terminated! */
	if ((pool_list_key = TlsAlloc()) == TLS_OUT_OF_INDEXES)
		@throw [OFInitializationFailedException newWithClass: self];
#endif
}







>
>
>
|
|
>
>
>
>
>
>
|







|







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
#define get_tls(t) TlsGetValue(t)
#define set_tls(t, v) TlsSetValue(t, v)
static DWORD pool_list_key;
#endif

#ifndef _WIN32
static void
release_list(void *list)
{
	of_list_object_t *first, *iter;
	IMP release;

	if ((first = [(OFList*)list first]) != NULL)
		release = [first->object methodFor: @selector(release)];

	for (iter = first; iter != NULL; iter = iter->next)
		release(iter->object, @selector(release));

	[(OFList*)list release];
}
#endif

@implementation OFAutoreleasePool
+ (void)initialize
{
#ifndef _WIN32
	if (pthread_key_create(&pool_list_key, release_list))
		@throw [OFInitializationFailedException newWithClass: self];
#else
	/* FIXME: Free stuff when thread is terminated! */
	if ((pool_list_key = TlsAlloc()) == TLS_OUT_OF_INDEXES)
		@throw [OFInitializationFailedException newWithClass: self];
#endif
}

Modified src/OFXMLFactory.m from [482f651e16] to [3b5278a052].

137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
	 */
	@try {
		va_start(args, data);

		while ((arg = va_arg(args, char*)) != NULL &&
		    (val = va_arg(args, char*)) != NULL) {
			esc_val = NULL;	/* Needed for our @catch */
			esc_val = [OFXMLFactory escapeCString: val];

			xf_resize_chars(&xml, &len, 1 + strlen(arg) + 2 +
			    strlen(esc_val) + 1, self);

			xml[i++] = ' ';
			memcpy(xml + i, arg, strlen(arg));
			i += strlen(arg);







|







137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
	 */
	@try {
		va_start(args, data);

		while ((arg = va_arg(args, char*)) != NULL &&
		    (val = va_arg(args, char*)) != NULL) {
			esc_val = NULL;	/* Needed for our @catch */
			esc_val = [self escapeCString: val];

			xf_resize_chars(&xml, &len, 1 + strlen(arg) + 2 +
			    strlen(esc_val) + 1, self);

			xml[i++] = ' ';
			memcpy(xml + i, arg, strlen(arg));
			i += strlen(arg);