ObjFW  Check-in [5f04d5b720]

Overview
Comment:Get rid of OFAutoreleasePool in of_asprintf.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5f04d5b720a9eeecf6de75a2b22d1537345f09a9206012730d0930a19631e18c
User & Date: js on 2012-08-19 23:26:26
Other Links: manifest | tags
Context
2012-08-20
00:20
exception.m: Fix cleanup. check-in: b2deb6c291 user: js tags: trunk
2012-08-19
23:26
Get rid of OFAutoreleasePool in of_asprintf. check-in: 5f04d5b720 user: js tags: trunk
21:27
Fix types for of_{dimension,rectangle,point}(). check-in: a82ee4d8c7 user: js tags: trunk
Changes

Modified src/of_asprintf.m from [2b51c08162] to [31d446cae5].

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdarg.h>
#include <stdbool.h>
#include <wchar.h>

#include <sys/types.h>

#import "OFString.h"
#import "OFAutoreleasePool.h"
#import "asprintf.h"

#import "macros.h"

#define MAX_SUBFORMAT_LEN 64

struct context {
	const char *format;
	size_t formatLen;







|

|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdarg.h>
#include <stdbool.h>
#include <wchar.h>

#include <sys/types.h>

#import "OFString.h"

#import "asprintf.h"
#import "autorelease.h"
#import "macros.h"

#define MAX_SUBFORMAT_LEN 64

struct context {
	const char *format;
	size_t formatLen;
285
286
287
288
289
290
291
292
293
294
295
296
297

298
299
300
301
302
303
304
	case '@':
		ctx->subformat[ctx->subformatLen - 1] = 's';

		@try {
			id object;

			if ((object = va_arg(ctx->arguments, id)) != nil) {
				OFAutoreleasePool *pool;

				pool = [[OFAutoreleasePool alloc] init];
				tmpLen = asprintf(&tmp, ctx->subformat,
				    [[object description] UTF8String]);
				[pool release];

			} else
				tmpLen = asprintf(&tmp, ctx->subformat,
				    "(nil)");
		} @catch (id e) {
			free(ctx->buffer);
			@throw e;
		}







|

<


|
>







285
286
287
288
289
290
291
292
293

294
295
296
297
298
299
300
301
302
303
304
	case '@':
		ctx->subformat[ctx->subformatLen - 1] = 's';

		@try {
			id object;

			if ((object = va_arg(ctx->arguments, id)) != nil) {
				void *pool = objc_autoreleasePoolPush();


				tmpLen = asprintf(&tmp, ctx->subformat,
				    [[object description] UTF8String]);

				objc_autoreleasePoolPop(pool);
			} else
				tmpLen = asprintf(&tmp, ctx->subformat,
				    "(nil)");
		} @catch (id e) {
			free(ctx->buffer);
			@throw e;
		}