ObjFW  Check-in [282aadb9df]

Overview
Comment:Always use [self alloc].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 282aadb9dfc8cf345a0724d7d4d3ece32aca6b21b21416f9404cd708f271d94f
User & Date: js on 2009-05-29 09:28:39
Other Links: manifest | tags
Context
2009-05-29
19:21
A few renames. check-in: 033054ad75 user: js tags: trunk
09:28
Always use [self alloc]. check-in: 282aadb9df user: js tags: trunk
2009-05-25
17:00
Improve objc_sync.m. check-in: 5337be0924 user: js tags: trunk
Changes

Modified src/OFFile.m from [2ae784c3e4] to [a323ff36d0].

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#import "OFFile.h"
#import "OFExceptions.h"

@implementation OFFile
+ fileWithPath: (OFString*)path
       andMode: (OFString*)mode
{
	return [[[OFFile alloc] initWithPath: path
				   andMode: mode] autorelease];
}

+ (void)changeModeOfFile: (OFString*)path
		  toMode: (mode_t)mode
{
	/*







|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#import "OFFile.h"
#import "OFExceptions.h"

@implementation OFFile
+ fileWithPath: (OFString*)path
       andMode: (OFString*)mode
{
	return [[[self alloc] initWithPath: path
				   andMode: mode] autorelease];
}

+ (void)changeModeOfFile: (OFString*)path
		  toMode: (mode_t)mode
{
	/*

Modified src/OFHashes.m from [e2ceddf0a6] to [dab01f181a].

113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
	buf[2] += c;
	buf[3] += d;
}

@implementation OFMD5Hash
+ md5Hash
{
	return [[[OFMD5Hash alloc] init] autorelease];
}

- init
{
	self = [super init];

	buf[0] = 0x67452301;







|







113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
	buf[2] += c;
	buf[3] += d;
}

@implementation OFMD5Hash
+ md5Hash
{
	return [[[self alloc] init] autorelease];
}

- init
{
	self = [super init];

	buf[0] = 0x67452301;
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365

	memcpy(&buffer[j], &buf[i], size - i);
}

@implementation OFSHA1Hash
+ sha1Hash
{
	return [[[OFSHA1Hash alloc] init] autorelease];
}

- init
{
	self = [super init];

	state[0] = 0x67452301;







|







351
352
353
354
355
356
357
358
359
360
361
362
363
364
365

	memcpy(&buffer[j], &buf[i], size - i);
}

@implementation OFSHA1Hash
+ sha1Hash
{
	return [[[self alloc] init] autorelease];
}

- init
{
	self = [super init];

	state[0] = 0x67452301;

Modified src/OFList.m from [d9bae66e58] to [b49c70c5e4].

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

#import "OFList.h"
#import "OFExceptions.h"

@implementation OFList
+ list
{
	return [[[OFList alloc] init] autorelease];
}

- init
{
	self = [super init];

	first = NULL;







|







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

#import "OFList.h"
#import "OFExceptions.h"

@implementation OFList
+ list
{
	return [[[self alloc] init] autorelease];
}

- init
{
	self = [super init];

	first = NULL;

Modified src/OFNumber.m from [0c2ce3eafa] to [886273d0e1].

221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
	default:							\
		@throw [OFInvalidFormatException newWithClass: isa];	\
	}

@implementation OFNumber
+ numberWithChar: (char)char_
{
	return [[[OFNumber alloc] initWithChar: char_] autorelease];
}

+ numberWithShort: (short)short_
{
	return [[[OFNumber alloc] initWithShort: short_] autorelease];
}

+ numberWithInt: (int)int_
{
	return [[[OFNumber alloc] initWithInt: int_] autorelease];
}

+ numberWithLong: (long)long_
{
	return [[[OFNumber alloc] initWithLong: long_] autorelease];
}

+ numberWithUChar: (unsigned char)uchar
{
	return [[[OFNumber alloc] initWithUChar: uchar] autorelease];
}

+ numberWithUShort: (unsigned short)ushort
{
	return [[[OFNumber alloc] initWithUShort: ushort] autorelease];
}

+ numberWithUInt: (unsigned int)uint
{
	return [[[OFNumber alloc] initWithUInt: uint] autorelease];
}

+ numberWithULong: (unsigned long)ulong
{
	return [[[OFNumber alloc] initWithULong: ulong] autorelease];
}

+ numberWithInt8: (int8_t)int8
{
	return [[[OFNumber alloc] initWithInt8: int8] autorelease];
}

+ numberWithInt16: (int16_t)int16
{
	return [[[OFNumber alloc] initWithInt16: int16] autorelease];
}

+ numberWithInt32: (int32_t)int32
{
	return [[[OFNumber alloc] initWithInt32: int32] autorelease];
}

+ numberWithInt64: (int64_t)int64
{
	return [[[OFNumber alloc] initWithInt64: int64] autorelease];
}

+ numberWithUInt8: (uint8_t)uint8
{
	return [[[OFNumber alloc] initWithUInt8: uint8] autorelease];
}

+ numberWithUInt16: (uint16_t)uint16
{
	return [[[OFNumber alloc] initWithUInt16: uint16] autorelease];
}

+ numberWithUInt32: (uint32_t)uint32
{
	return [[[OFNumber alloc] initWithUInt32: uint32] autorelease];
}

+ numberWithUInt64: (uint64_t)uint64
{
	return [[[OFNumber alloc] initWithUInt64: uint64] autorelease];
}

+ numberWithSize: (size_t)size
{
	return [[[OFNumber alloc] initWithSize: size] autorelease];
}

+ numberWithSSize: (ssize_t)ssize
{
	return [[[OFNumber alloc] initWithSSize: ssize] autorelease];
}

+ numberWithIntMax: (intmax_t)intmax
{
	return [[[OFNumber alloc] initWithIntMax: intmax] autorelease];
}

+ numberWithUIntMax: (uintmax_t)uintmax
{
	return [[[OFNumber alloc] initWithIntMax: uintmax] autorelease];
}

+ numberWithPtrDiff: (ptrdiff_t)ptrdiff
{
	return [[[OFNumber alloc] initWithPtrDiff: ptrdiff] autorelease];
}

+ numberWithIntPtr: (intptr_t)intptr
{
	return [[[OFNumber alloc] initWithIntPtr: intptr] autorelease];
}

+ numberWithFloat: (float)float_
{
	return [[[OFNumber alloc] initWithFloat: float_] autorelease];
}

+ numberWithDouble: (double)double_
{
	return [[[OFNumber alloc] initWithDouble: double_] autorelease];
}

- initWithChar: (char)char_
{
	self = [super init];

	value.char_ = char_;







|




|




|




|




|




|




|




|




|




|




|




|




|




|




|




|




|




|




|




|




|




|




|




|







221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
	default:							\
		@throw [OFInvalidFormatException newWithClass: isa];	\
	}

@implementation OFNumber
+ numberWithChar: (char)char_
{
	return [[[self alloc] initWithChar: char_] autorelease];
}

+ numberWithShort: (short)short_
{
	return [[[self alloc] initWithShort: short_] autorelease];
}

+ numberWithInt: (int)int_
{
	return [[[self alloc] initWithInt: int_] autorelease];
}

+ numberWithLong: (long)long_
{
	return [[[self alloc] initWithLong: long_] autorelease];
}

+ numberWithUChar: (unsigned char)uchar
{
	return [[[self alloc] initWithUChar: uchar] autorelease];
}

+ numberWithUShort: (unsigned short)ushort
{
	return [[[self alloc] initWithUShort: ushort] autorelease];
}

+ numberWithUInt: (unsigned int)uint
{
	return [[[self alloc] initWithUInt: uint] autorelease];
}

+ numberWithULong: (unsigned long)ulong
{
	return [[[self alloc] initWithULong: ulong] autorelease];
}

+ numberWithInt8: (int8_t)int8
{
	return [[[self alloc] initWithInt8: int8] autorelease];
}

+ numberWithInt16: (int16_t)int16
{
	return [[[self alloc] initWithInt16: int16] autorelease];
}

+ numberWithInt32: (int32_t)int32
{
	return [[[self alloc] initWithInt32: int32] autorelease];
}

+ numberWithInt64: (int64_t)int64
{
	return [[[self alloc] initWithInt64: int64] autorelease];
}

+ numberWithUInt8: (uint8_t)uint8
{
	return [[[self alloc] initWithUInt8: uint8] autorelease];
}

+ numberWithUInt16: (uint16_t)uint16
{
	return [[[self alloc] initWithUInt16: uint16] autorelease];
}

+ numberWithUInt32: (uint32_t)uint32
{
	return [[[self alloc] initWithUInt32: uint32] autorelease];
}

+ numberWithUInt64: (uint64_t)uint64
{
	return [[[self alloc] initWithUInt64: uint64] autorelease];
}

+ numberWithSize: (size_t)size
{
	return [[[self alloc] initWithSize: size] autorelease];
}

+ numberWithSSize: (ssize_t)ssize
{
	return [[[self alloc] initWithSSize: ssize] autorelease];
}

+ numberWithIntMax: (intmax_t)intmax
{
	return [[[self alloc] initWithIntMax: intmax] autorelease];
}

+ numberWithUIntMax: (uintmax_t)uintmax
{
	return [[[self alloc] initWithIntMax: uintmax] autorelease];
}

+ numberWithPtrDiff: (ptrdiff_t)ptrdiff
{
	return [[[self alloc] initWithPtrDiff: ptrdiff] autorelease];
}

+ numberWithIntPtr: (intptr_t)intptr
{
	return [[[self alloc] initWithIntPtr: intptr] autorelease];
}

+ numberWithFloat: (float)float_
{
	return [[[self alloc] initWithFloat: float_] autorelease];
}

+ numberWithDouble: (double)double_
{
	return [[[self alloc] initWithDouble: double_] autorelease];
}

- initWithChar: (char)char_
{
	self = [super init];

	value.char_ = char_;

Modified src/OFSocket.h from [2df5bc02b8] to [ddb40125e5].

41
42
43
44
45
46
47





48
49
50
51
52
#else
	SOCKET		sock;
#endif
	struct sockaddr	*saddr;
	socklen_t	saddr_len;
}






/**
 * Enables/disables non-blocking I/O.
 */
- setBlocking: (BOOL)enable;
@end







>
>
>
>
>





41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#else
	SOCKET		sock;
#endif
	struct sockaddr	*saddr;
	socklen_t	saddr_len;
}

/**
 * \return A new autoreleased OFTCPSocket
 */
+ socket;

/**
 * Enables/disables non-blocking I/O.
 */
- setBlocking: (BOOL)enable;
@end

Modified src/OFSocket.m from [17814ea548] to [309a255317].

30
31
32
33
34
35
36





37
38
39
40
41
42
43
	if (self != [OFSocket class])
		return;

	if (WSAStartup(MAKEWORD(2, 0), &wsa))
		@throw [OFInitializationFailedException newWithClass: self];
}
#endif






- init
{
	self = [super init];

	sock = INVALID_SOCKET;
	saddr = NULL;







>
>
>
>
>







30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
	if (self != [OFSocket class])
		return;

	if (WSAStartup(MAKEWORD(2, 0), &wsa))
		@throw [OFInitializationFailedException newWithClass: self];
}
#endif

+ socket
{
	return [[[self alloc] init] autorelease];
}

- init
{
	self = [super init];

	sock = INVALID_SOCKET;
	saddr = NULL;

Modified src/OFTCPSocket.h from [fabcbf213d] to [c2014cc1a4].

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#import "OFSocket.h"
#import "OFString.h"

/**
 * The OFTCPSocket class provides functions to create and use sockets.
 */
@interface OFTCPSocket: OFSocket {}
/**
 * \return A new autoreleased OFTCPSocket
 */
+ socket;

/**
 * Initializes an already allocated OFTCPSocket.
 *
 * \return An initialized OFTCPSocket
 */
- init;

/**
 * Connect the OFTCPSocket to the specified destination.
 *
 * \param service The service on the node to connect to
 * \param node The node to connect to
 */
- connectToService: (OFString*)service







<
<
<
<
<
<
<
<
<
<
<
<







12
13
14
15
16
17
18












19
20
21
22
23
24
25
#import "OFSocket.h"
#import "OFString.h"

/**
 * The OFTCPSocket class provides functions to create and use sockets.
 */
@interface OFTCPSocket: OFSocket {}












/**
 * Connect the OFTCPSocket to the specified destination.
 *
 * \param service The service on the node to connect to
 * \param node The node to connect to
 */
- connectToService: (OFString*)service

Modified src/OFTCPSocket.m from [804f167c59] to [9070a0d7b2].

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
+ (void)initialize
{
	if (self == [OFTCPSocket class])
		lock = [[OFObject alloc] init];
}
#endif

+ socket
{
	return [[[OFTCPSocket alloc] init] autorelease];
}

- init
{
	self = [super init];

	sock = INVALID_SOCKET;
	saddr = NULL;

	return self;
}

- (void)dealloc
{
	if (sock != INVALID_SOCKET)
		close(sock);

	[super dealloc];
}







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







38
39
40
41
42
43
44















45
46
47
48
49
50
51
+ (void)initialize
{
	if (self == [OFTCPSocket class])
		lock = [[OFObject alloc] init];
}
#endif
















- (void)dealloc
{
	if (sock != INVALID_SOCKET)
		close(sock);

	[super dealloc];
}

Modified src/OFThread.m from [acf9e5847a] to [d1dce164e0].

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
	return 0;
}
#endif

@implementation OFThread
+ threadWithObject: (id)obj
{
	/*
	 * This is one of the rare cases where the convenience method should
	 * use self instead of the class.
	 *
	 * The reason is that you derive from OFThread and reimplement main.
	 * If OFThread instead of self would be used here, the reimplemented
	 * main would never be called.
	 */
	return [[[self alloc] initWithObject: obj] autorelease];
}

+ setObject: (id)obj
  forTLSKey: (OFTLSKey*)key
{
	id old = [self objectForTLSKey: key];







<
<
<
<
<
<
<
<







30
31
32
33
34
35
36








37
38
39
40
41
42
43
	return 0;
}
#endif

@implementation OFThread
+ threadWithObject: (id)obj
{








	return [[[self alloc] initWithObject: obj] autorelease];
}

+ setObject: (id)obj
  forTLSKey: (OFTLSKey*)key
{
	id old = [self objectForTLSKey: key];
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
	[super dealloc];
}
@end

@implementation OFTLSKey
+ tlsKeyWithDestructor: (void(*)(void*))destructor
{
	return [[[OFTLSKey alloc] initWithDestructor: destructor] autorelease];
}

- initWithDestructor: (void(*)(void*))destructor
{
	Class c;

	self = [super init];







|







146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
	[super dealloc];
}
@end

@implementation OFTLSKey
+ tlsKeyWithDestructor: (void(*)(void*))destructor
{
	return [[[self alloc] initWithDestructor: destructor] autorelease];
}

- initWithDestructor: (void(*)(void*))destructor
{
	Class c;

	self = [super init];