Modified src/OFArray.m
from [006ecd6265]
to [5ae87127d9].
︙ | | |
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
-
-
+
+
|
{
OFObject *container;
size_t count;
id *buffer;
container = [[[OFObject alloc] init] autorelease];
count = [self count];
buffer = [container allocMemoryForNItems: [self count]
ofSize: sizeof(*buffer)];
buffer = [container allocMemoryWithItemSize: sizeof(*buffer)
count: [self count]];
[self getObjects: buffer
inRange: of_range(0, count)];
return buffer;
}
|
︙ | | |
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
|
-
-
+
+
|
OFArray *ret;
id *buffer;
if (![self isKindOfClass: [OFMutableArray class]])
return [OFArray_subarray arrayWithArray: self
range: range];
buffer = [self allocMemoryForNItems: range.length
ofSize: sizeof(*buffer)];
buffer = [self allocMemoryWithItemSize: sizeof(*buffer)
count: range.length];
@try {
[self getObjects: buffer
inRange: range];
ret = [OFArray arrayWithObjects: buffer
count: range.length];
|
︙ | | |
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
|
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
|
-
-
+
+
-
-
+
+
|
#endif
#ifdef OF_HAVE_BLOCKS
- (OFArray*)mappedArrayUsingBlock: (of_array_map_block_t)block
{
OFArray *ret;
size_t count = [self count];
id *tmp = [self allocMemoryForNItems: count
ofSize: sizeof(id)];
id *tmp = [self allocMemoryWithItemSize: sizeof(id)
count: count];
@try {
[self enumerateObjectsUsingBlock: ^ (id object, size_t index,
BOOL *stop) {
tmp[index] = block(object, index);
}];
ret = [OFArray arrayWithObjects: tmp
count: count];
} @finally {
[self freeMemory: tmp];
}
return ret;
}
- (OFArray*)filteredArrayUsingBlock: (of_array_filter_block_t)block
{
OFArray *ret;
size_t count = [self count];
id *tmp = [self allocMemoryForNItems: count
ofSize: sizeof(id)];
id *tmp = [self allocMemoryWithItemSize: sizeof(id)
count: count];
@try {
__block size_t i = 0;
[self enumerateObjectsUsingBlock: ^ (id object, size_t index,
BOOL *stop) {
if (block(object, index))
|
︙ | | |
Modified src/OFArray_adjacent.m
from [c8a1da4bf7]
to [7c4a615aae].
︙ | | |
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
-
-
+
+
|
@throw e;
}
@try {
for (i = 0; i < count; i++)
[objects[i] retain];
[array addNItems: count
fromCArray: objects];
[array addItemsFromCArray: objects
count: count];
} @catch (id e) {
for (i = 0; i < count; i++)
[objects[i] release];
/* Prevent double-release of objects */
[array release];
array = nil;
|
︙ | | |
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
-
-
+
+
|
@try {
size_t i;
for (i = 0; i < count; i++)
[objects[i] retain];
[array addNItems: count
fromCArray: objects];
[array addItemsFromCArray: objects
count: count];
} @catch (id e) {
size_t i;
for (i = 0; i < count; i++)
[objects[i] release];
[self release];
|
︙ | | |
Modified src/OFAutoreleasePool.m
from [9f23f6d996]
to [bc3a0d2a2f].
︙ | | |
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
-
-
+
+
-
-
+
+
|
#endif
}
if (previousPool != nil)
previousPool->nextPool = self;
size = GROW_SIZE;
objects = [self allocMemoryForNItems: GROW_SIZE
ofSize: sizeof(id)];
objects = [self allocMemoryWithItemSize: sizeof(id)
count: GROW_SIZE];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (void)_addObject: (id)object
{
if (count + 1 > size) {
objects = [self resizeMemory: objects
toNItems: size + GROW_SIZE
ofSize: sizeof(id)];
itemSize: sizeof(id)
count: size + GROW_SIZE];
size += GROW_SIZE;
}
objects[count] = object;
count++;
}
|
︙ | | |
Modified src/OFDataArray.h
from [f2dc48f29f]
to [4922f55b79].
︙ | | |
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
+
-
-
+
-
|
/**
* \brief Adds an item to the OFDataArray at the specified index.
*
* \param item A pointer to an arbitrary item
* \param index The index where the item should be added
*/
- (void)addItem: (const void*)item
atIndex: (size_t)index;
- (void)insertItem: (const void*)item
atIndex: (size_t)index;
/**
* \brief Adds items from a C array to the OFDataArray.
*
* \param nItems The number of items to add
* \param count The number of items to add
* \param cArray A C array containing the items to add
*/
- (void)addNItems: (size_t)nItems
fromCArray: (const void*)cArray;
- (void)addItemsFromCArray: (const void*)cArray
count: (size_t)count;
/**
* \brief Adds items from a C array to the OFDataArray at the specified index.
*
* \param nItems The number of items to add
* \param cArray A C array containing the items to add
* \param index The index where the items should be added
* \param count The number of items to add
*/
- (void)addNItems: (size_t)nItems
fromCArray: (const void*)cArray
atIndex: (size_t)index;
- (void)insertItemsFromCArray: (const void*)cArray
atIndex: (size_t)index
count: (size_t)count;
/**
* \brief Removes the item at the specified index.
*
* \param index The index of the item to remove
*/
- (void)removeItemAtIndex: (size_t)index;
/**
* \brief Removes the specified amount of items from the end of the OFDataArray.
*
* \param nItems The number of items to remove
*/
- (void)removeNItems: (size_t)nItems;
/**
* \brief Removes the specified amount of items at the specified index.
*
* \param nItems The number of items to remove
* \param range The range of items to remove
* \param index The index at which the items are removed
*/
- (void)removeNItems: (size_t)nItems
- (void)removeItemsInRange: (of_range_t)range;
atIndex: (size_t)index;
/**
* \brief Removes the last item.
*/
- (void)removeLastItem;
/**
|
︙ | | |
Modified src/OFDataArray.m
from [f620eb9fde]
to [1c8a76eb56].
︙ | | |
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
-
-
+
+
|
char *buffer = [self allocMemoryWithSize: of_pagesize];
while (![file isAtEndOfStream]) {
size_t length;
length = [file readNBytes: of_pagesize
intoBuffer: buffer];
[self addNItems: length
fromCArray: buffer];
[self addItemsFromCArray: buffer
count: length];
}
[self freeMemory: buffer];
} @finally {
[file release];
}
} @catch (id e) {
|
︙ | | |
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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
+
-
-
+
+
-
+
-
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
+
-
-
-
+
-
-
+
+
-
-
+
+
-
-
+
+
|
- (void)addItem: (const void*)item
{
if (SIZE_MAX - count < 1)
@throw [OFOutOfRangeException exceptionWithClass: isa];
data = [self resizeMemory: data
toNItems: count + 1
ofSize: itemSize];
itemSize: itemSize
count: count + 1];
memcpy(data + count * itemSize, item, itemSize);
count++;
}
- (void)addItem: (const void*)item
atIndex: (size_t)index
- (void)insertItem: (const void*)item
atIndex: (size_t)index
{
[self addNItems: 1
fromCArray: item
atIndex: index];
[self insertItemsFromCArray: item
atIndex: index
count: 1];
}
- (void)addNItems: (size_t)nItems
fromCArray: (const void*)cArray
- (void)addItemsFromCArray: (const void*)cArray
count: (size_t)nItems
{
if (nItems > SIZE_MAX - count)
@throw [OFOutOfRangeException exceptionWithClass: isa];
data = [self resizeMemory: data
toNItems: count + nItems
ofSize: itemSize];
itemSize: itemSize
count: count + nItems];
memcpy(data + count * itemSize, cArray, nItems * itemSize);
count += nItems;
}
- (void)addNItems: (size_t)nItems
fromCArray: (const void*)cArray
atIndex: (size_t)index
- (void)insertItemsFromCArray: (const void*)cArray
atIndex: (size_t)index
count: (size_t)nItems
{
if (nItems > SIZE_MAX - count)
if (nItems > SIZE_MAX - count || index > count)
@throw [OFOutOfRangeException exceptionWithClass: isa];
data = [self resizeMemory: data
toNItems: count + nItems
ofSize: itemSize];
itemSize: itemSize
count: count + nItems];
memmove(data + (index + nItems) * itemSize, data + index * itemSize,
(count - index) * itemSize);
memcpy(data + index * itemSize, cArray, nItems * itemSize);
count += nItems;
}
- (void)removeItemAtIndex: (size_t)index
{
[self removeNItems: 1
[self removeItemsInRange: of_range(index, 1)];
atIndex: index];
}
- (void)removeNItems: (size_t)nItems
- (void)removeItemsInRange: (of_range_t)range
{
if (nItems > count)
if (range.start + range.length > count)
@throw [OFOutOfRangeException exceptionWithClass: isa];
memmove(data + range.start * itemSize,
count -= nItems;
@try {
data = [self resizeMemory: data
toNItems: count
ofSize: itemSize];
} @catch (OFOutOfMemoryException *e) {
/* We don't really care, as we only made it smaller */
}
}
data + (range.start + range.length) * itemSize,
- (void)removeNItems: (size_t)nItems
atIndex: (size_t)index
{
if (nItems > count)
@throw [OFOutOfRangeException exceptionWithClass: isa];
(count - range.start - range.length) * itemSize);
memmove(data + index * itemSize, data + (index + nItems) * itemSize,
(count - index - nItems) * itemSize);
count -= nItems;
count -= range.length;
@try {
data = [self resizeMemory: data
toNItems: count
ofSize: itemSize];
itemSize: itemSize
count: count];
} @catch (OFOutOfMemoryException *e) {
/* We don't really care, as we only made it smaller */
}
}
- (void)removeLastItem
{
if (count < 1)
@throw [OFOutOfRangeException exceptionWithClass: isa];
count--;
@try {
data = [self resizeMemory: data
toNItems: count
ofSize: itemSize];
itemSize: itemSize
count: count];
} @catch (OFOutOfMemoryException *e) {
/* We don't care, as we only made it smaller */
}
}
- (void)removeAllItems
{
[self freeMemory: data];
data = NULL;
count = 0;
}
- copy
{
OFDataArray *copy = [[isa alloc] initWithItemSize: itemSize];
[copy addNItems: count
fromCArray: data];
[copy addItemsFromCArray: data
count: count];
return copy;
}
- (BOOL)isEqual: (id)object
{
OFDataArray *otherDataArray;
|
︙ | | |
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
|
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
|
-
-
+
+
-
-
-
+
+
+
-
+
+
-
+
-
+
-
-
-
-
+
-
-
-
-
-
-
+
-
-
-
-
-
+
-
-
-
-
-
-
+
|
memcpy(data + count * itemSize, item, itemSize);
count++;
size = newSize;
}
- (void)addNItems: (size_t)nItems
fromCArray: (const void*)cArray
- (void)addItemsFromCArray: (const void*)cArray
count: (size_t)nItems
{
size_t newSize, lastPageByte;
if (nItems > SIZE_MAX - count || count + nItems > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException exceptionWithClass: isa];
lastPageByte = of_pagesize - 1;
newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte;
if (size != newSize)
data = [self resizeMemory: data
toSize: newSize];
memcpy(data + count * itemSize, cArray, nItems * itemSize);
count += nItems;
size = newSize;
}
- (void)addNItems: (size_t)nItems
fromCArray: (const void*)cArray
atIndex: (size_t)index
- (void)insertItemsFromCArray: (const void*)cArray
atIndex: (size_t)index
count: (size_t)nItems
{
size_t newSize, lastPageByte;
if (nItems > SIZE_MAX - count || count + nItems > SIZE_MAX / itemSize)
if (nItems > SIZE_MAX - count || index > count ||
count + nItems > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException exceptionWithClass: isa];
lastPageByte = of_pagesize - 1;
newSize = ((count + nItems) * itemSize + lastPageByte) & ~lastPageByte;
if (size != newSize)
data = [self resizeMemory: data
toSize: newSize];
memmove(data + (index + nItems) * itemSize, data + index * itemSize,
(count - index) * itemSize);
memcpy(data + index * itemSize, cArray, nItems * itemSize);
count += nItems;
size = newSize;
}
- (void)removeNItems: (size_t)nItems
- (void)removeItemsInRange: (of_range_t)range
{
size_t newSize, lastPageByte;
if (nItems > count)
if (range.start + range.length > count)
@throw [OFOutOfRangeException exceptionWithClass: isa];
count -= nItems;
lastPageByte = of_pagesize - 1;
newSize = (count * itemSize + lastPageByte) & ~lastPageByte;
memmove(data + range.start * itemSize,
if (size != newSize)
data = [self resizeMemory: data
toSize: newSize];
size = newSize;
}
data + (range.start + range.length) * itemSize,
- (void)removeNItems: (size_t)nItems
atIndex: (size_t)index
{
size_t newSize, lastPageByte;
(count - range.start - range.length) * itemSize);
if (nItems > count)
@throw [OFOutOfRangeException exceptionWithClass: isa];
memmove(data + index * itemSize, data + (index + nItems) * itemSize,
(count - index - nItems) * itemSize);
count -= nItems;
count -= range.length;
lastPageByte = of_pagesize - 1;
newSize = (count * itemSize + lastPageByte) & ~lastPageByte;
if (size != newSize)
data = [self resizeMemory: data
toSize: newSize];
size = newSize;
|
︙ | | |
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
|
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
|
-
-
+
|
count--;
lastPageByte = of_pagesize - 1;
newSize = (count * itemSize + lastPageByte) & ~lastPageByte;
if (size != newSize) {
@try {
data = [self resizeMemory: data
toNItems: count
ofSize: newSize];
toSize: newSize];
} @catch (OFOutOfMemoryException *e) {
/* We don't care, as we only made it smaller */
}
size = newSize;
}
}
|
︙ | | |
Modified src/OFDictionary.m
from [7004ce02ac]
to [170550a25e].
︙ | | |
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
|
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
|
-
-
+
+
|
return NO;
}
- (OFArray*)allKeys
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
id *keys = [self allocMemoryForNItems: [self count]
ofSize: sizeof(id)];
id *keys = [self allocMemoryWithItemSize: sizeof(id)
count: [self count]];
OFArray *ret;
OFEnumerator *enumerator;
id key;
size_t i = 0;
pool = [[OFAutoreleasePool alloc] init];
enumerator = [self keyEnumerator];
|
︙ | | |
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
|
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
|
-
-
+
+
|
return ret;
}
- (OFArray*)allObjects
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
id *objects = [self allocMemoryForNItems: [self count]
ofSize: sizeof(id)];
id *objects = [self allocMemoryWithItemSize: sizeof(id)
count: [self count]];
OFArray *ret;
OFEnumerator *enumerator;
id object;
size_t i = 0;
pool = [[OFAutoreleasePool alloc] init];
enumerator = [self objectEnumerator];
|
︙ | | |
Modified src/OFDictionary_hashtable.m
from [2511a02b50]
to [c77b46c66d].
︙ | | |
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
-
-
+
+
|
[OFMutableDictionary_hashtable class]])
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
hashtable = (OFDictionary_hashtable*)dictionary;
data = [self allocMemoryForNItems: hashtable->size
ofSize: sizeof(*data)];
data = [self allocMemoryWithItemSize: sizeof(*data)
count: hashtable->size];
for (i = 0; i < hashtable->size; i++)
data[i] = NULL;
size = hashtable->size;
count = hashtable->count;
|
︙ | | |
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
-
-
+
+
|
for (newSize = 1; newSize < count; newSize <<= 1);
if (count * 4 / newSize >= 3)
newSize <<= 1;
if (newSize == 0)
@throw [OFOutOfRangeException exceptionWithClass: isa];
data = [self allocMemoryForNItems: newSize
ofSize: sizeof(*data)];
data = [self allocMemoryWithItemSize: sizeof(*data)
count: newSize];
for (i = 0; i < newSize; i++)
data[i] = NULL;
size = newSize;
pool = [[OFAutoreleasePool alloc] init];
|
︙ | | |
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
-
-
+
+
|
struct of_dictionary_hashtable_bucket *bucket;
if (key == nil || object == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: isa
selector: _cmd];
data = [self allocMemoryForNItems: 2
ofSize: sizeof(*data)];
data = [self allocMemoryWithItemSize: sizeof(*data)
count: 2];
size = 2;
for (i = 0; i < size; i++)
data[i] = NULL;
i = [key hash] & 1;
|
︙ | | |
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
-
-
+
+
|
for (newSize = 1; newSize < count; newSize <<= 1);
if (count * 4 / newSize >= 3)
newSize <<= 1;
if (newSize == 0)
@throw [OFOutOfRangeException exceptionWithClass: isa];
data = [self allocMemoryForNItems: newSize
ofSize: sizeof(*data)];
data = [self allocMemoryWithItemSize: sizeof(*data)
count: newSize];
for (j = 0; j < newSize; j++)
data[j] = NULL;
size = newSize;
for (i = 0; i < count; i++) {
|
︙ | | |
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
|
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
|
-
-
+
+
|
for (newSize = 1; newSize < count; newSize <<= 1);
if (count * 4 / newSize >= 3)
newSize <<= 1;
if (newSize == 0)
@throw [OFOutOfRangeException exceptionWithClass: isa];
data = [self allocMemoryForNItems: newSize
ofSize: sizeof(*data)];
data = [self allocMemoryWithItemSize: sizeof(*data)
count: newSize];
for (j = 0; j < newSize; j++)
data[j] = NULL;
size = newSize;
/* Add first key / object pair */
|
︙ | | |
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
|
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
|
-
-
+
+
|
return NO;
}
- (OFArray*)allKeys
{
OFArray *ret;
id *keys = [self allocMemoryForNItems: count
ofSize: sizeof(id)];
id *keys = [self allocMemoryWithItemSize: sizeof(*keys)
count: count];
size_t i, j;
for (i = j = 0; i < size; i++)
if (data[i] != NULL && data[i] != DELETED)
keys[j++] = data[i]->key;
assert(j == count);
|
︙ | | |
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
|
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
|
-
-
+
+
|
return ret;
}
- (OFArray*)allObjects
{
OFArray *ret;
id *objects = [self allocMemoryForNItems: count
ofSize: sizeof(id)];
id *objects = [self allocMemoryWithItemSize: sizeof(*objects)
count: count];
size_t i, j;
for (i = j = 0; i < size; i++)
if (data[i] != NULL && data[i] != DELETED)
objects[j++] = data[i]->object;
assert(j == count);
|
︙ | | |
Modified src/OFHTTPRequest.m
from [4b826a148e]
to [456aec5d03].
︙ | | |
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
|
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
|
-
-
+
+
|
[delegate request: self
didReceiveData: buffer
withLength: length];
[pool2 releaseObjects];
bytesReceived += length;
[data addNItems: length
fromCArray: buffer];
[data addItemsFromCArray: buffer
count: length];
toRead -= length;
}
@try {
line = [sock readLine];
} @catch (OFInvalidEncodingException *e) {
|
︙ | | |
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
|
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
|
-
-
+
+
|
intoBuffer: buffer]) > 0) {
[delegate request: self
didReceiveData: buffer
withLength: length];
[pool2 releaseObjects];
bytesReceived += length;
[data addNItems: length
fromCArray: buffer];
[data addItemsFromCArray: buffer
count: length];
if (contentLengthHeader != nil &&
bytesReceived >= contentLength)
break;
}
}
|
︙ | | |
Modified src/OFMutableArray.h
from [7429d32994]
to [cef5851cfb].
︙ | | |
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
|
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
|
-
+
-
+
-
+
-
-
+
+
|
/**
* \brief An abstract class for storing, adding and removing objects in anr
* array.
*/
@interface OFMutableArray: OFArray
/**
* \brief Adds an object to the OFArray.
* \brief Adds an object to the end of the array.
*
* \param object An object to add
*/
- (void)addObject: (id)object;
/**
* \brief Adds an object to the OFArray at the specified index.
* \brief Inserts an object to the OFArray at the specified index.
*
* \param object An object to add
* \param index The index where the object should be added
* \param index The index where the object should be inserted
*/
- (void)addObject: (id)object
atIndex: (size_t)index;
- (void)insertObject: (id)object
atIndex: (size_t)index;
/**
* \brief Replaces the first object equivalent to the specified object with the
* other specified object.
*
* \param oldObject The object to replace
* \param newObject The replacement object
|
︙ | | |
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
-
-
-
-
-
-
-
|
/**
* \brief Removes the object at the specified index.
*
* \param index The index of the object to remove
*/
- (void)removeObjectAtIndex: (size_t)index;
/**
* \brief Removes the specified amount of objects from the end of the OFArray.
*
* \param nObjects The number of objects to remove
*/
- (void)removeNObjects: (size_t)nObjects;
/**
* \brief Removes the object in the specified range.
*
* \param range The range of the objects to remove
*/
- (void)removeObjectsInRange: (of_range_t)range;
|
︙ | | |
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
-
+
-
-
+
+
-
-
+
+
|
*
* \param block The block which returns a new object for each object
*/
- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block;
#endif
/**
* \brief Swaps the objects at the specified indices.
* \brief Exchange the objects at the specified indices.
*
* \param index1 The index of the first object to swap
* \param index2 The index of the second object to swap
* \param index1 The index of the first object to exchange
* \param index2 The index of the second object to exchange
*/
- (void)swapObjectAtIndex: (size_t)index1
withObjectAtIndex: (size_t)index2;
- (void)exchangeObjectAtIndex: (size_t)index1
withObjectAtIndex: (size_t)index2;
/**
* \brief Sorts the array.
*/
- (void)sort;
/**
|
︙ | | |
Modified src/OFMutableArray.m
from [833d3b17ca]
to [2fdb683912].
︙ | | |
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
+
+
|
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#include <string.h>
#include <assert.h>
#import "OFMutableArray.h"
#import "OFMutableArray_adjacent.h"
#import "OFAutoreleasePool.h"
#import "OFEnumerationMutationException.h"
#import "OFInvalidArgumentException.h"
|
︙ | | |
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
-
-
+
+
-
-
+
+
|
i++;
while ([[array objectAtIndex: j] compare: pivot] !=
OF_ORDERED_ASCENDING && j > left)
j--;
if (i < j)
[array swapObjectAtIndex: i
withObjectAtIndex: j];
[array exchangeObjectAtIndex: i
withObjectAtIndex: j];
} while (i < j);
if ([[array objectAtIndex: i] compare: pivot] == OF_ORDERED_DESCENDING)
[array swapObjectAtIndex: i
withObjectAtIndex: right];
[array exchangeObjectAtIndex: i
withObjectAtIndex: right];
if (i > 0)
quicksort(array, left, i - 1);
quicksort(array, i + 1, right);
}
@implementation OFMutableArray_placeholder
|
︙ | | |
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
-
-
+
+
-
-
+
+
|
- copy
{
return [[OFArray alloc] initWithArray: self];
}
- (void)addObject: (id)object
{
[self addObject: object
atIndex: [self count]];
[self insertObject: object
atIndex: [self count]];
}
- (void)addObject: (id)object
atIndex: (size_t)index
- (void)insertObject: (id)object
atIndex: (size_t)index
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
- (void)replaceObjectAtIndex: (size_t)index
withObject: (id)object
|
︙ | | |
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
|
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
|
-
-
-
-
-
-
-
+
+
+
-
+
-
+
-
-
+
+
|
[self removeObjectAtIndex: i];
return;
}
}
}
- (void)removeNObjects: (size_t)nObjects
{
size_t count = [self count];
[self removeObjectsInRange: of_range(count - nObjects, nObjects)];
}
- (void)removeObjectsInRange: (of_range_t)range
{
size_t i;
for (i = 0; i < range.length; i++)
[self removeObjectAtIndex: range.start];
}
- (void)removeLastObject
{
size_t count = [self count];
if (count > 0)
[self removeNObjects: 1];
[self removeObjectAtIndex: count - 1];
}
- (void)removeAllObjects
{
[self removeNObjects: [self count]];
[self removeObjectsInRange: of_range(0, [self count])];
}
#ifdef OF_HAVE_BLOCKS
- (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block
{
[self enumerateObjectsUsingBlock: ^ (id object, size_t index,
BOOL *stop) {
[self replaceObjectAtIndex: index
withObject: block(object, index, stop)];
}];
}
#endif
- (void)swapObjectAtIndex: (size_t)index1
withObjectAtIndex: (size_t)index2
- (void)exchangeObjectAtIndex: (size_t)index1
withObjectAtIndex: (size_t)index2
{
id object1 = [self objectAtIndex: index1];
id object2 = [self objectAtIndex: index2];
[object1 retain];
@try {
[self replaceObjectAtIndex: index1
|
︙ | | |
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
|
-
-
+
+
|
{
size_t i, j, count = [self count];
if (count == 0 || count == 1)
return;
for (i = 0, j = count - 1; i < j; i++, j--)
[self swapObjectAtIndex: i
withObjectAtIndex: j];
[self exchangeObjectAtIndex: i
withObjectAtIndex: j];
}
- (void)makeImmutable
{
}
@end
|
Modified src/OFMutableArray_adjacent.m
from [a923c5af53]
to [489af893ca].
︙ | | |
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
-
-
+
+
-
-
+
+
|
{
[array addItem: &object];
[object retain];
mutations++;
}
- (void)addObject: (id)object
atIndex: (size_t)index
- (void)insertObject: (id)object
atIndex: (size_t)index
{
[array addItem: &object
atIndex: index];
[array insertItem: &object
atIndex: index];
[object retain];
mutations++;
}
- (void)replaceObject: (id)oldObject
withObject: (id)newObject
|
︙ | | |
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
-
-
+
+
|
id object = [self objectAtIndex: index];
[array removeItemAtIndex: index];
[object release];
mutations++;
}
- (void)removeNObjects: (size_t)nObjects
{
id *objects = [array cArray], *copy;
size_t i, count = [array count];
if (nObjects > count)
@throw [OFOutOfRangeException exceptionWithClass: isa];
copy = [self allocMemoryForNItems: nObjects
ofSize: sizeof(id)];
memcpy(copy, objects + (count - nObjects), nObjects * sizeof(id));
@try {
[array removeNItems: nObjects];
mutations++;
for (i = 0; i < nObjects; i++)
[copy[i] release];
} @finally {
[self freeMemory: copy];
}
}
- (void)removeAllObjects
{
id *objects = [array cArray];
size_t i, count = [array count];
for (i = 0; i < count; i++)
[objects[i] release];
[array removeAllItems];
}
- (void)removeObjectsInRange: (of_range_t)range
{
id *objects = [array cArray], *copy;
size_t i, count = [array count];
if (range.length > count - range.start)
@throw [OFOutOfRangeException exceptionWithClass: isa];
copy = [self allocMemoryForNItems: range.length
ofSize: sizeof(id)];
copy = [self allocMemoryWithItemSize: sizeof(*copy)
count: range.length];
memcpy(copy, objects + range.start, range.length * sizeof(id));
@try {
[array removeNItems: range.length
[array removeItemsInRange: range];
atIndex: range.start];
mutations++;
for (i = 0; i < range.length; i++)
[copy[i] release];
} @finally {
[self freeMemory: copy];
}
}
- (void)removeLastObject
{
id object = [self objectAtIndex: [array count] - 1];
[array removeLastItem];
[object release];
mutations++;
}
- (void)swapObjectAtIndex: (size_t)index1
withObjectAtIndex: (size_t)index2
- (void)exchangeObjectAtIndex: (size_t)index1
withObjectAtIndex: (size_t)index2
{
id *objects = [array cArray];
size_t count = [array count];
id tmp;
if (index1 >= count || index2 >= count)
@throw [OFOutOfRangeException exceptionWithClass: isa];
|
︙ | | |
Modified src/OFMutableDictionary_hashtable.m
from [13d8064ed3]
to [959d2e2496].
︙ | | |
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
-
-
+
+
|
newSize = size >> 1;
else
return;
if (newSize == 0)
@throw [OFOutOfRangeException exceptionWithClass: isa];
newData = [self allocMemoryForNItems: newSize
ofSize: sizeof(*newData)];
newData = [self allocMemoryWithItemSize: sizeof(*newData)
count: newSize];
for (i = 0; i < newSize; i++)
newData[i] = NULL;
for (i = 0; i < size; i++) {
if (data[i] != NULL && data[i] != DELETED) {
uint32_t j, last;
|
︙ | | |
Modified src/OFMutableSet.m
from [112af5c677]
to [f111a1faac].
︙ | | |
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
-
-
+
+
|
- (void)intersectSet: (OFSet*)set
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
size_t count = [self count];
id *cArray;
cArray = [self allocMemoryForNItems: count
ofSize: sizeof(id)];
cArray = [self allocMemoryWithItemSize: sizeof(id)
count: count];
@try {
OFEnumerator *enumerator = [self objectEnumerator];
id object;
size_t i = 0;
while ((object = [enumerator nextObject]) != nil) {
|
︙ | | |
Modified src/OFMutableString_UTF8.m
from [6763734ad5]
to [3f21e1777e].
︙ | | |
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
-
-
+
+
|
if ((t = table[0][*p]) != 0)
*p = t;
return;
}
unicodeLen = [self length];
unicodeString = [self allocMemoryForNItems: unicodeLen
ofSize: sizeof(of_unichar_t)];
unicodeString = [self allocMemoryWithItemSize: sizeof(of_unichar_t)
count: unicodeLen];
i = j = 0;
newCStringLength = 0;
while (i < s->cStringLength) {
cLen = of_string_utf8_to_unicode(s->cString + i,
s->cStringLength - i, &c);
|
︙ | | |
Modified src/OFObject.h
from [9092415875]
to [2f8f69a869].
︙ | | |
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
|
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
|
-
-
+
+
-
-
+
+
|
/**
* \brief Allocates memory for the specified number of items and stores it in
* the object's memory pool.
*
* It will be free'd automatically when the object is deallocated.
*
* \param nItems The number of items to allocate
* \param size The size of each item to allocate
* \param itemSize The size of each item to allocate
* \param count The number of items to allocate
* \return A pointer to the allocated memory
*/
- (void*)allocMemoryForNItems: (size_t)nItems
ofSize: (size_t)size;
- (void*)allocMemoryWithItemSize: (size_t)itemSize
count: (size_t)count;
/**
* \brief Resizes memory in the object's memory pool to the specified size.
*
* If the pointer is NULL, this is equivalent to allocating memory.
* If the size is 0, this is equivalent to freeing memory.
*
|
︙ | | |
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
|
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
|
-
-
+
+
-
-
+
+
|
* \brief Resizes memory in the object's memory pool to the specific number of
* items of the specified size.
*
* If the pointer is NULL, this is equivalent to allocating memory.
* If the size or number of items is 0, this is equivalent to freeing memory.
*
* \param pointer A pointer to the already allocated memory
* \param nItems The number of items to resize to
* \param size The size of each item to resize to
* \param itemSize The size of each item to resize to
* \param count The number of items to resize to
* \return A pointer to the resized memory chunk
*/
- (void*)resizeMemory: (void*)pointer
toNItems: (size_t)nItems
ofSize: (size_t)size;
itemSize: (size_t)itemSize
count: (size_t)count;
/**
* \brief Frees allocated memory and removes it from the object's memory pool.
*
* Does nothing if the pointer is NULL.
*
* \param pointer A pointer to the allocated memory
|
︙ | | |
Modified src/OFObject.m
from [26d577e585]
to [71be745647].
︙ | | |
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
|
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
|
-
-
+
+
-
+
-
+
-
+
|
PRE_IVAR->lastMem->next = preMem;
PRE_IVAR->lastMem = preMem;
return (char*)pointer + PRE_MEM_ALIGN;
}
- (void*)allocMemoryForNItems: (size_t)nItems
ofSize: (size_t)size
- (void*)allocMemoryWithItemSize: (size_t)itemSize
count: (size_t)count
{
if (nItems == 0 || size == 0)
if (itemSize == 0 || count == 0)
return NULL;
if (nItems > SIZE_MAX / size)
if (count > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException exceptionWithClass: isa];
return [self allocMemoryWithSize: nItems * size];
return [self allocMemoryWithSize: itemSize * count];
}
- (void*)resizeMemory: (void*)pointer
toSize: (size_t)size
{
void *new;
struct pre_mem *preMem;
|
︙ | | |
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
|
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
|
-
-
+
+
-
-
+
+
-
+
-
+
-
+
|
PRE_IVAR->lastMem = preMem;
}
return (char*)new + PRE_MEM_ALIGN;
}
- (void*)resizeMemory: (void*)pointer
toNItems: (size_t)nItems
ofSize: (size_t)size
itemSize: (size_t)itemSize
count: (size_t)count
{
if (pointer == NULL)
return [self allocMemoryForNItems: nItems
ofSize: size];
return [self allocMemoryWithItemSize: itemSize
count: count];
if (nItems == 0 || size == 0) {
if (itemSize == 0 || count == 0) {
[self freeMemory: pointer];
return NULL;
}
if (nItems > SIZE_MAX / size)
if (count > SIZE_MAX / itemSize)
@throw [OFOutOfRangeException exceptionWithClass: isa];
return [self resizeMemory: pointer
toSize: nItems * size];
toSize: itemSize * count];
}
- (void)freeMemory: (void*)pointer
{
if (pointer == NULL)
return;
|
︙ | | |
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
|
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
|
-
-
+
+
-
-
+
+
|
*/
+ (void*)allocMemoryWithSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
+ (void*)allocMemoryForNItems: (size_t)nItems
ofSize: (size_t)size
+ (void*)allocMemoryWithItemSize: (size_t)itemSize
count: (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
+ (void*)resizeMemory: (void*)pointer
toSize: (size_t)size
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
+ (void*)resizeMemory: (void*)pointer
toNItems: (size_t)nItems
ofSize: (size_t)size
itemSize: (size_t)itemSize
count: (size_t)count
{
@throw [OFNotImplementedException exceptionWithClass: self
selector: _cmd];
}
+ (void)freeMemory: (void*)pointer
{
|
︙ | | |
Modified src/OFProcess.m
from [53a70ada66]
to [6f88407ce3].
︙ | | |
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
-
-
+
+
|
switch ((pid = fork())) {
case 0:;
OFString **objects = [arguments objects];
size_t i, count = [arguments count];
char **argv;
argv = [self allocMemoryForNItems: count + 2
ofSize: sizeof(char*)];
argv = [self allocMemoryWithItemSize: sizeof(char*)
count: count + 2];
argv[0] = (char*)[programName cStringWithEncoding:
OF_STRING_ENCODING_NATIVE];
for (i = 0; i < count; i++)
argv[i + 1] = (char*)[objects[i]
cStringWithEncoding:
|
︙ | | |
Modified src/OFStream.m
from [79c2ad057e]
to [a84cb06e69].
︙ | | |
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
|
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
|
-
+
-
-
-
+
+
+
-
-
+
+
-
+
-
-
+
+
|
return [self readDataArrayWithItemSize: 1
andNItems: nItems];
}
- (OFDataArray*)readDataArrayWithItemSize: (size_t)itemSize
andNItems: (size_t)nItems
{
OFDataArray *da;
OFDataArray *dataArray;
char *tmp;
da = [OFDataArray dataArrayWithItemSize: itemSize];
tmp = [self allocMemoryForNItems: nItems
ofSize: itemSize];
dataArray = [OFDataArray dataArrayWithItemSize: itemSize];
tmp = [self allocMemoryWithItemSize: itemSize
count: nItems];
@try {
[self readExactlyNBytes: nItems * itemSize
intoBuffer: tmp];
[da addNItems: nItems
fromCArray: tmp];
[dataArray addItemsFromCArray: tmp
count: nItems];
} @finally {
[self freeMemory: tmp];
}
return da;
return dataArray;
}
- (OFDataArray*)readDataArrayTillEndOfStream
{
OFDataArray *dataArray;
char *buffer;
dataArray = [OFDataArray dataArray];
buffer = [self allocMemoryWithSize: of_pagesize];
@try {
while (![self isAtEndOfStream]) {
size_t length;
length = [self readNBytes: of_pagesize
intoBuffer: buffer];
[dataArray addNItems: length
fromCArray: buffer];
[dataArray addItemsFromCArray: buffer
count: length];
}
} @finally {
[self freeMemory: buffer];
}
return dataArray;
}
|
︙ | | |
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
|
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
|
-
-
+
+
|
#ifdef OF_BIG_ENDIAN
[self writeNBytes: size
fromBuffer: buffer];
#else
uint16_t *tmp;
tmp = [self allocMemoryForNItems: nInt16s
ofSize: sizeof(uint16_t)];
tmp = [self allocMemoryWithItemSize: sizeof(uint16_t)
count: nInt16s];
@try {
size_t i;
for (i = 0; i < nInt16s; i++)
tmp[i] = of_bswap16(buffer[i]);
|
︙ | | |
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
|
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
|
-
-
+
+
|
#ifdef OF_BIG_ENDIAN
[self writeNBytes: size
fromBuffer: buffer];
#else
uint32_t *tmp;
tmp = [self allocMemoryForNItems: nInt32s
ofSize: sizeof(uint32_t)];
tmp = [self allocMemoryWithItemSize: sizeof(uint32_t)
count: nInt32s];
@try {
size_t i;
for (i = 0; i < nInt32s; i++)
tmp[i] = of_bswap32(buffer[i]);
|
︙ | | |
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
|
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
|
-
-
+
+
|
#ifdef OF_BIG_ENDIAN
[self writeNBytes: size
fromBuffer: buffer];
#else
uint64_t *tmp;
tmp = [self allocMemoryForNItems: nInt64s
ofSize: sizeof(uint64_t)];
tmp = [self allocMemoryWithItemSize: sizeof(uint64_t)
count: nInt64s];
@try {
size_t i;
for (i = 0; i < nInt64s; i++)
tmp[i] = of_bswap64(buffer[i]);
|
︙ | | |
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
|
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
|
-
-
+
+
|
#ifdef OF_FLOAT_BIG_ENDIAN
[self writeNBytes: size
fromBuffer: buffer];
#else
float *tmp;
tmp = [self allocMemoryForNItems: nFloats
ofSize: sizeof(float)];
tmp = [self allocMemoryWithItemSize: sizeof(float)
count: nFloats];
@try {
size_t i;
for (i = 0; i < nFloats; i++)
tmp[i] = of_bswap_float(buffer[i]);
|
︙ | | |
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
|
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
|
-
-
+
+
|
#ifdef OF_FLOAT_BIG_ENDIAN
[self writeNBytes: size
fromBuffer: buffer];
#else
double *tmp;
tmp = [self allocMemoryForNItems: nDoubles
ofSize: sizeof(double)];
tmp = [self allocMemoryWithItemSize: sizeof(double)
count: nDoubles];
@try {
size_t i;
for (i = 0; i < nDoubles; i++)
tmp[i] = of_bswap_double(buffer[i]);
|
︙ | | |
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
|
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
|
-
-
+
+
|
#ifndef OF_BIG_ENDIAN
[self writeNBytes: size
fromBuffer: buffer];
#else
uint16_t *tmp;
tmp = [self allocMemoryForNItems: nInt16s
ofSize: sizeof(uint16_t)];
tmp = [self allocMemoryWithItemSize: sizeof(uint16_t)
count: nInt16s];
@try {
size_t i;
for (i = 0; i < nInt16s; i++)
tmp[i] = of_bswap16(buffer[i]);
|
︙ | | |
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
|
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
|
-
-
+
+
|
#ifndef OF_BIG_ENDIAN
[self writeNBytes: size
fromBuffer: buffer];
#else
uint32_t *tmp;
tmp = [self allocMemoryForNItems: nInt32s
ofSize: sizeof(uint32_t)];
tmp = [self allocMemoryWithItemSize: sizeof(uint32_t)
count: nInt32s];
@try {
size_t i;
for (i = 0; i < nInt32s; i++)
tmp[i] = of_bswap32(buffer[i]);
|
︙ | | |
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
|
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
|
-
-
+
+
|
#ifndef OF_BIG_ENDIAN
[self writeNBytes: size
fromBuffer: buffer];
#else
uint64_t *tmp;
tmp = [self allocMemoryForNItems: nInt64s
ofSize: sizeof(uint64_t)];
tmp = [self allocMemoryWithItemSize: sizeof(uint64_t)
count: nInt64s];
@try {
size_t i;
for (i = 0; i < nInt64s; i++)
tmp[i] = of_bswap64(buffer[i]);
|
︙ | | |
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
|
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
|
-
-
+
+
|
#ifndef OF_FLOAT_BIG_ENDIAN
[self writeNBytes: size
fromBuffer: buffer];
#else
float *tmp;
tmp = [self allocMemoryForNItems: nFloats
ofSize: sizeof(float)];
tmp = [self allocMemoryWithItemSize: sizeof(float)
count: nFloats];
@try {
size_t i;
for (i = 0; i < nFloats; i++)
tmp[i] = of_bswap_float(buffer[i]);
|
︙ | | |
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
|
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
|
-
-
+
+
|
#ifndef OF_FLOAT_BIG_ENDIAN
[self writeNBytes: size
fromBuffer: buffer];
#else
double *tmp;
tmp = [self allocMemoryForNItems: nDoubles
ofSize: sizeof(double)];
tmp = [self allocMemoryWithItemSize: sizeof(double)
count: nDoubles];
@try {
size_t i;
for (i = 0; i < nDoubles; i++)
tmp[i] = of_bswap_double(buffer[i]);
|
︙ | | |
Modified src/OFStreamObserver.m
from [89d321be6d]
to [75b0a6497b].
︙ | | |
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
-
-
+
+
|
if (getsockname(cancelFD[0], (struct sockaddr*)&cancelAddr,
&cancelAddrLen))
@throw [OFInitializationFailedException
exceptionWithClass: isa];
#endif
maxFD = cancelFD[0];
FDToStream = [self allocMemoryForNItems: maxFD + 1
ofSize: sizeof(OFStream*)];
FDToStream = [self allocMemoryWithItemSize: sizeof(OFStream*)
count: maxFD + 1];
FDToStream[cancelFD[0]] = nil;
#ifdef OF_THREADS
mutex = [[OFMutex alloc] init];
#endif
} @catch (id e) {
[self release];
|
︙ | | |
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
-
-
+
+
|
int fd = queueFDsCArray[i];
if ((action & QUEUE_ACTION) == QUEUE_ADD) {
if (fd > maxFD) {
maxFD = fd;
FDToStream = [self
resizeMemory: FDToStream
toNItems: maxFD + 1
ofSize: sizeof(OFStream*)];
itemSize: sizeof(OFStream*)
count: maxFD + 1];
}
FDToStream[fd] = stream;
}
if ((action & QUEUE_ACTION) == QUEUE_REMOVE) {
/* FIXME: Maybe downsize? */
|
︙ | | |
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
|
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
|
-
-
-
+
+
+
|
break;
default:
assert(0);
}
}
[queue removeNObjects: count];
[queueInfo removeNItems: count];
[queueFDs removeNItems: count];
[queue removeAllObjects];
[queueInfo removeAllItems];
[queueFDs removeAllItems];
} @finally {
[mutex unlock];
}
}
- (void)observe
{
|
︙ | | |
Modified src/OFStreamObserver_kqueue.m
from [688eaf3047]
to [c2387049cc].
︙ | | |
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
-
+
|
[pool release];
@throw [OFOutOfMemoryException exceptionWithClass: isa];
default:
assert(0);
}
}
[changeList removeNItems: [changeList count]];
[changeList removeAllItems];
if (events == 0) {
[pool release];
return NO;
}
for (i = 0; i < events; i++) {
|
︙ | | |
Modified src/OFString+JSONValue.h
from [db1f76de2d]
to [9180243d68].
︙ | | |
24
25
26
27
28
29
30
31
32
33
34
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
+
+
+
+
+
+
+
+
+
+
+
+
|
}
#endif
@interface OFString (JSONValue)
/**
* \brief Creates an object from the JSON value of the string.
*
* \note This also allows parsing JSON5, an extension of JSON. See
* http://json5.org/ for more details.
*
* \warning Although not specified by the JSON specification, this can also
* return primitives like strings and numbers. The rationale behind
* this is that most JSON parsers allow JSON data just consisting of a
* single primitive, leading to realworld JSON files sometimes only
* consisting of a single primitive. Therefore, you should not make any
* assumptions about the object returned by this method if you don't
* want your program to terminate due to a message not understood, but
* instead check the returned object using -[isKindOfClass:].
*
* \return An object
*/
- (id)JSONValue;
@end
|
Modified src/OFString+JSONValue.m
from [9190d7a166]
to [06182df9e0].
︙ | | |
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
+
|
}
static inline OFString*
parseString(const char *restrict *pointer, const char *stop)
{
char *buffer;
size_t i = 0;
char delimiter = **pointer;
if (++(*pointer) + 1 >= stop)
return nil;
if ((buffer = malloc(stop - *pointer)) == NULL)
return nil;
|
︙ | | |
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
-
|
return nil;
}
/* Normal character */
if ((c1 & 0xFC00) != 0xD800) {
l = of_string_unicode_to_utf8(c1,
buffer + i);
if (l == 0) {
free(buffer);
return nil;
}
i += l;
*pointer += 5;
|
︙ | | |
217
218
219
220
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
|
217
218
219
220
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
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
|
-
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
|
return nil;
}
c = (((c1 & 0x3FF) << 10) |
(c2 & 0x3FF)) + 0x10000;
l = of_string_unicode_to_utf8(c, buffer + i);
if (l == 0) {
free(buffer);
return nil;
}
i += l;
*pointer += 11;
break;
case '\r':
(*pointer)++;
if (*pointer < stop && **pointer == '\n')
(*pointer)++;
break;
case '\n':
(*pointer)++;
break;
default:
free(buffer);
return nil;
free(buffer);
return nil;
}
/* End of string found */
} else if (**pointer == '"') {
} else if (**pointer == delimiter) {
OFString *ret;
@try {
ret = [OFString stringWithUTF8String: buffer
length: i];
} @finally {
free(buffer);
}
(*pointer)++;
return ret;
/* Newlines in strings are disallowed */
} else if (**pointer == '\n' || **pointer == '\r') {
free(buffer);
return nil;
} else {
buffer[i++] = **pointer;
(*pointer)++;
}
}
free(buffer);
return nil;
}
static inline OFString*
parseIdentifier(const char *restrict *pointer, const char *stop)
{
char *buffer;
size_t i = 0;
if ((buffer = malloc(stop - *pointer)) == NULL)
return nil;
while (*pointer < stop) {
if ((**pointer >= 'a' && **pointer <= 'z') ||
(**pointer >= 'A' && **pointer <= 'Z') ||
(**pointer >= '0' && **pointer <= '9') ||
**pointer == '_' || **pointer == '$' ||
(**pointer & 0x80)) {
buffer[i++] = **pointer;
(*pointer)++;
} else if (**pointer == '\\') {
uint16_t c1, c2;
of_unichar_t c;
size_t l;
if (++(*pointer) >= stop || **pointer != 'u') {
free(buffer);
return nil;
}
c1 = parseUnicodeEscape(*pointer - 1, stop);
if (c1 == 0xFFFF) {
free(buffer);
return nil;
}
/* Low surrogate */
if ((c1 & 0xFC00) == 0xDC00) {
free(buffer);
return nil;
}
/* Normal character */
if ((c1 & 0xFC00) != 0xD800) {
l = of_string_unicode_to_utf8(c1, buffer + i);
if (l == 0) {
free(buffer);
return nil;
}
i += l;
*pointer += 5;
continue;
}
/*
* If we are still here, we only got one UTF-16
* surrogate and now need to get the other one in order
* to produce UTF-8 and not CESU-8.
*/
c2 = parseUnicodeEscape(*pointer + 5, stop);
if (c2 == 0xFFFF) {
free(buffer);
return nil;
}
c = (((c1 & 0x3FF) << 10) | (c2 & 0x3FF)) + 0x10000;
l = of_string_unicode_to_utf8(c, buffer + i);
if (l == 0) {
free(buffer);
return nil;
}
i += l;
*pointer += 11;
} else {
OFString *ret;
if (i == 0 || (buffer[0] >= '0' && buffer[0] <= '9')) {
free(buffer);
return nil;
}
@try {
ret = [OFString stringWithUTF8String: buffer
length: i];
} @finally {
free(buffer);
}
(*pointer)++;
return ret;
} else {
buffer[i++] = **pointer;
(*pointer)++;
}
}
/*
* It is never possible to end with an identifier, thus we should never
free(buffer);
* reach stop.
*/
return nil;
}
static inline OFMutableArray*
parseArray(const char *restrict *pointer, const char *stop)
{
OFMutableArray *array = [OFMutableArray array];
if (++(*pointer) >= stop)
return nil;
while (**pointer != ']') {
id object;
skipWhitespacesAndComments(pointer, stop);
if (*pointer >= stop)
return nil;
if (**pointer == ']')
break;
if (**pointer == ',') {
(*pointer)++;
skipWhitespacesAndComments(pointer, stop);
if (*pointer >= stop || **pointer != ']')
return nil;
break;
}
if ((object = nextObject(pointer, stop)) == nil)
return nil;
[array addObject: object];
skipWhitespacesAndComments(pointer, stop);
|
︙ | | |
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
|
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
|
skipWhitespacesAndComments(pointer, stop);
if (*pointer >= stop)
return nil;
if (**pointer == '}')
break;
if (**pointer == ',') {
(*pointer)++;
skipWhitespacesAndComments(pointer, stop);
if (*pointer >= stop || **pointer != '}')
return nil;
break;
}
skipWhitespacesAndComments(pointer, stop);
if (*pointer + 1 >= stop)
return nil;
if ((**pointer >= 'a' && **pointer <= 'z') ||
(**pointer >= 'A' && **pointer <= 'Z') ||
**pointer == '_' || **pointer == '$' || **pointer == '\\')
key = parseIdentifier(pointer, stop);
else
if ((key = nextObject(pointer, stop)) == nil)
key = nextObject(pointer, stop);
if (key == nil)
return nil;
skipWhitespacesAndComments(pointer, stop);
if (*pointer + 1 >= stop || **pointer != ':')
return nil;
(*pointer)++;
|
︙ | | |
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
|
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
|
+
-
+
+
+
+
+
|
return dictionary;
}
static inline OFNumber*
parseNumber(const char *restrict *pointer, const char *stop)
{
BOOL isHex = (*pointer + 1 < stop && (*pointer)[1] == 'x');
BOOL hasDecimal = NO;
size_t i;
OFString *string;
OFNumber *number;
for (i = 1; *pointer + i < stop; i++) {
for (i = 0; *pointer + i < stop; i++) {
if ((*pointer)[i] == '.')
hasDecimal = YES;
if ((*pointer)[i] == ' ' || (*pointer)[i] == '\t' ||
(*pointer)[i] == '\r' || (*pointer)[i] == '\n' ||
(*pointer)[i] == ',' || (*pointer)[i] == ']' ||
(*pointer)[i] == '}')
break;
}
string = [[OFString alloc] initWithUTF8String: *pointer
length: i];
*pointer += i;
@try {
if (hasDecimal)
number = [OFNumber numberWithDouble:
[string doubleValue]];
else if (isHex)
number = [OFNumber numberWithIntMax:
[string hexadecimalValue]];
else
number = [OFNumber numberWithIntMax:
[string decimalValue]];
} @finally {
[string release];
}
return number;
}
static id
nextObject(const char *restrict *pointer, const char *stop)
{
skipWhitespacesAndComments(pointer, stop);
if (*pointer >= stop)
return nil;
switch (**pointer) {
case '"':
case '\'':
return parseString(pointer, stop);
case '[':
return parseArray(pointer, stop);
case '{':
return parseDictionary(pointer, stop);
case 't':
if (*pointer + 3 >= stop)
|
︙ | | |
442
443
444
445
446
447
448
449
450
451
452
453
454
455
|
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
|
+
|
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '-':
case '.':
return parseNumber(pointer, stop);
default:
return nil;
}
}
@implementation OFString (JSONValue)
|
︙ | | |
Modified src/OFString.h
from [2bed144e84]
to [56e5646eb4].
︙ | | |
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
|
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
|
-
+
+
+
+
+
+
+
+
+
|
*/
- (OFString*)substringWithRange: (of_range_t)range;
/**
* \brief Creates a new string by appending another string.
*
* \param string The string to append
* \return A new autoreleased OFString with the specified string appended
* \return A new, autoreleased OFString with the specified string appended
*/
- (OFString*)stringByAppendingString: (OFString*)string;
/**
* \brief Creates a new string by appending a path component.
*
* \param component The path component to append
* \return A new, autoreleased OFString with the path component appended
*/
- (OFString*)stringByAppendingPathComponent: (OFString*)component;
/**
* \brief Creates a new string by prepending another string.
*
* \param string The string to prepend
* \return A new autoreleased OFString with the specified string prepended
*/
- (OFString*)stringByPrependingString: (OFString*)string;
|
︙ | | |
Modified src/OFString.m
from [bcea8a4ed5]
to [788fd6f59d].
︙ | | |
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
|
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
|
+
+
+
+
+
|
new = [OFMutableString stringWithString: self];
[new appendString: string];
[new makeImmutable];
return new;
}
- (OFString*)stringByAppendingPathComponent: (OFString*)component
{
return [OFString stringWithPath: self, component, nil];
}
- (OFString*)stringByPrependingString: (OFString*)string
{
OFMutableString *new = [[string mutableCopy] autorelease];
[new appendString: self];
|
︙ | | |
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
|
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
|
-
-
+
+
|
const of_unichar_t *prefixString;
size_t prefixLength;
int compare;
if ((prefixLength = [prefix length]) > [self length])
return NO;
tmp = [self allocMemoryForNItems: prefixLength
ofSize: sizeof(of_unichar_t)];
tmp = [self allocMemoryWithItemSize: sizeof(of_unichar_t)
count: prefixLength];
@try {
OFAutoreleasePool *pool;
[self getCharacters: tmp
inRange: of_range(0, prefixLength)];
pool = [[OFAutoreleasePool alloc] init];
|
︙ | | |
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
|
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
|
-
-
+
+
|
int compare;
if ((suffixLength = [suffix length]) > [self length])
return NO;
length = [self length];
tmp = [self allocMemoryForNItems: suffixLength
ofSize: sizeof(of_unichar_t)];
tmp = [self allocMemoryWithItemSize: sizeof(of_unichar_t)
count: suffixLength];
@try {
OFAutoreleasePool *pool;
[self getCharacters: tmp
inRange: of_range(length - suffixLength,
suffixLength)];
|
︙ | | |
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
|
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
|
-
-
+
+
-
-
+
+
|
- (const of_unichar_t*)unicodeString
{
OFObject *object = [[[OFObject alloc] init] autorelease];
size_t length = [self length];
of_unichar_t *ret;
ret = [object allocMemoryForNItems: length + 1
ofSize: sizeof(of_unichar_t)];
ret = [object allocMemoryWithItemSize: sizeof(of_unichar_t)
count: length + 1];
[self getCharacters: ret
inRange: of_range(0, length)];
ret[length] = 0;
return ret;
}
- (const uint16_t*)UTF16String
{
OFObject *object = [[[OFObject alloc] init] autorelease];
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
const of_unichar_t *unicodeString = [self unicodeString];
size_t length = [self length];
uint16_t *ret;
size_t i, j;
/* Allocate memory for the worst case */
ret = [object allocMemoryForNItems: length * 2 + 1
ofSize: sizeof(uint16_t)];
ret = [object allocMemoryWithItemSize: sizeof(uint16_t)
count: length * 2 + 1];
j = 0;
for (i = 0; i < length; i++) {
of_unichar_t c = unicodeString[i];
if (c > 0x10FFFF)
|
︙ | | |
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
|
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
|
-
-
+
+
|
ret[j++] = of_bswap16_if_le(c);
}
ret[j] = 0;
@try {
ret = [object resizeMemory: ret
toNItems: j + 1
ofSize: sizeof(uint16_t)];
itemSize: sizeof(uint16_t)
count: j + 1];
} @catch (OFOutOfMemoryException *e) {
/* We don't care, as we only tried to make it smaller */
}
[pool release];
return ret;
|
︙ | | |
Modified src/OFString_UTF8.m
from [03beefc292]
to [5faa6d539b].
︙ | | |
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
|
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
|
-
-
+
+
|
- (const of_unichar_t*)unicodeString
{
OFObject *object = [[[OFObject alloc] init] autorelease];
of_unichar_t *ret;
size_t i, j;
ret = [object allocMemoryForNItems: s->length + 1
ofSize: sizeof(of_unichar_t)];
ret = [object allocMemoryWithItemSize: sizeof(of_unichar_t)
count: s->length + 1];
i = 0;
j = 0;
while (i < s->cStringLength) {
of_unichar_t c;
size_t cLen;
|
︙ | | |
Modified src/OFThreadPool.h
from [2701771c31]
to [a3f951f884].
︙ | | |
118
119
120
121
122
123
124
125
|
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
+
+
+
+
+
+
+
|
object: (id)object;
#endif
/**
* \brief Waits until all threads have finished.
*/
- (void)waitUntilFinished;
/**
* \brief Returns the size of the thread pool.
*
* \return The size of the thread pool
*/
- (size_t)size;
@end
|
Modified src/OFThreadPool.m
from [7cccc445b9]
to [59038be60b].
︙ | | |
379
380
381
382
383
384
385
386
|
379
380
381
382
383
384
385
386
387
388
389
390
391
|
+
+
+
+
+
|
- (void)dispatchWithBlock: (of_thread_pool_block_t)block
object: (id)object
{
[self _dispatchJob: [OFThreadPoolJob jobWithBlock: block
object: object]];
}
#endif
- (size_t)size
{
return size;
}
@end
|
Modified src/OFXMLElement.m
from [05fab1ecc3]
to [23e15b2038].
︙ | | |
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
|
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
|
-
-
+
+
|
indentation: ind
level: level + 1];
else
child = [childrenObjects[j]
XMLStringWithIndentation: ind
level: level + 1];
[tmp addNItems: [child UTF8StringLength]
fromCArray: [child UTF8String]];
[tmp addItemsFromCArray: [child UTF8String]
count: [child UTF8StringLength]];
}
if (indent)
[tmp addItem: "\n"];
length += [tmp count] + [name UTF8StringLength] + 2 +
(indent ? level * indentation : 0);
|
︙ | | |
Modified src/OFXMLParser.m
from [8f2d46a92b]
to [2619682154].
︙ | | |
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
-
-
+
+
-
-
+
+
|
static state_function lookupTable[OF_XMLPARSER_NUM_STATES];
static OF_INLINE void
cache_append(OFDataArray *cache, const char *string,
of_string_encoding_t encoding, size_t length)
{
if (OF_LIKELY(encoding == OF_STRING_ENCODING_UTF_8))
[cache addNItems: length
fromCArray: string];
[cache addItemsFromCArray: string
count: length];
else {
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFString *tmp = [OFString stringWithCString: string
encoding: encoding
length: length];
[cache addNItems: [tmp UTF8StringLength]
fromCArray: [tmp UTF8String]];
[cache addItemsFromCArray: [tmp UTF8String]
count: [tmp UTF8StringLength]];
[pool release];
}
}
static OFString*
transform_string(OFDataArray *cache, size_t cut, BOOL unescape,
OFObject <OFStringXMLUnescapingDelegate> *delegate)
|
︙ | | |
Modified src/atomic.h
from [0e0a7c1a99]
to [874337cdfb].
︙ | | |
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
|
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
|
-
-
+
+
-
|
#elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM)
int32_t r;
__asm__ (
"xorl %0, %0\n\t"
"lock\n\t"
"cmpxchg %2, %3\n\t"
"jne 0\n\t"
"incl %0\n"
"sete %b0\n\t"
"movzbl %b0, %0"
"0:"
: "=&r"(r)
: "a"(o), "r"(n), "m"(*p)
);
return r;
#elif defined(OF_HAVE_GCC_ATOMIC_OPS)
return __sync_bool_compare_and_swap(p, o, n);
|
︙ | | |
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
|
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
|
-
-
+
+
-
|
#elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM)
int r;
__asm__ (
"xorl %0, %0\n\t"
"lock\n\t"
"cmpxchg %2, %3\n\t"
"jne 0\n\t"
"incl %0\n"
"sete %b0\n\t"
"movzbl %b0, %0"
"0:"
: "=&r"(r)
: "a"(o), "r"(n), "m"(*p)
);
return r;
#elif defined(OF_HAVE_GCC_ATOMIC_OPS)
return __sync_bool_compare_and_swap(p, o, n);
|
︙ | | |
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
|
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
|
-
-
+
+
-
|
#elif defined(OF_X86_ASM) || defined(OF_AMD64_ASM)
int r;
__asm__ (
"xorl %0, %0\n\t"
"lock\n\t"
"cmpxchg %2, %3\n\t"
"jne 0\n\t"
"incl %0\n"
"sete %b0\n\t"
"movzbl %b0, %0"
"0:"
: "=&r"(r)
: "a"(o), "r"(n), "m"(*p)
);
return r;
#elif defined(OF_HAVE_GCC_ATOMIC_OPS)
return __sync_bool_compare_and_swap(p, o, n);
#elif defined(OF_HAVE_OSATOMIC)
return OSAtomicCompareAndSwapPtrBarrier(o, n, p);
#endif
}
|
Modified src/base64.m
from [467c9771cc]
to [b831cbbe10].
︙ | | |
146
147
148
149
150
151
152
153
154
155
156
157
158
|
146
147
148
149
150
151
152
153
154
155
156
157
158
|
-
-
+
+
|
sb |= tmp;
db[0] = (sb & 0xFF0000) >> 16;
db[1] = (sb & 0x00FF00) >> 8;
db[2] = sb & 0x0000FF;
[data addNItems: count
fromCArray: db];
[data addItemsFromCArray: db
count: count];
}
return YES;
}
|
Modified tests/OFArrayTests.m
from [19f0fe9122]
to [550ae86871].
︙ | | |
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
-
-
+
+
|
TEST(@"-[description]",
[[a[0] description ]isEqual: @"(\n\tFoo,\n\tBar,\n\tBaz\n)"])
TEST(@"-[addObject:]", R([m[0] addObject: c_ary[0]]) &&
R([m[0] addObject: c_ary[2]]))
TEST(@"-[addObject:atIndex:]", R([m[0] addObject: c_ary[1]
atIndex: 1]))
TEST(@"-[insertObject:atIndex:]", R([m[0] insertObject: c_ary[1]
atIndex: 1]))
TEST(@"-[count]", [m[0] count] == 3 && [a[0] count] == 3 &&
[a[1] count] == 3)
TEST(@"-[isEqual:]", [m[0] isEqual: a[0]] && [a[0] isEqual: a[1]])
TEST(@"-[objectAtIndex:]",
|
︙ | | |
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
-
-
-
-
-
|
TEST(@"-[removeObject:]",
R([m[0] removeObject: c_ary[0]]) && [m[0] count] == 2)
TEST(@"-[removeObjectIdenticalTo:]",
R([m[0] removeObjectIdenticalTo: c_ary[2]]) && [m[0] count] == 1)
[m[0] addObject: c_ary[0]];
[m[0] addObject: c_ary[1]];
TEST(@"-[removeNObjects:]", R([m[0] removeNObjects: 2]) &&
[m[0] count] == 1 && [[m[0] objectAtIndex: 0] isEqual: c_ary[0]])
m[1] = [[a[0] mutableCopy] autorelease];
TEST(@"-[removeObjectAtIndex:]", R([m[1] removeObjectAtIndex: 1]) &&
[m[1] count] == 2 && [[m[1] objectAtIndex: 1] isEqual: c_ary[2]])
m[1] = [[a[0] mutableCopy] autorelease];
TEST(@"-[removeObjectsInRange:]",
R([m[1] removeObjectsInRange: of_range(0, 2)]) &&
|
︙ | | |
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
-
-
+
+
+
|
TEST(@"-[sortedArray]",
[[m[1] sortedArray] isEqual: ([OFArray arrayWithObjects:
@"0", @"Bar", @"Baz", @"Foo", @"z", nil])])
EXPECT_EXCEPTION(@"Detect out of range in -[objectAtIndex:]",
OFOutOfRangeException, [a[0] objectAtIndex: [a[0] count]])
EXPECT_EXCEPTION(@"Detect out of range in -[removeNObjects:]",
OFOutOfRangeException, [m[0] removeNObjects: [m[0] count] + 1])
EXPECT_EXCEPTION(@"Detect out of range in -[removeObjectsInRange:]",
OFOutOfRangeException, [m[0] removeObjectsInRange:
of_range(0, [m[0] count] + 1)])
TEST(@"-[componentsJoinedByString:]",
(a[1] = [OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil]) &&
[[a[1] componentsJoinedByString: @" "] isEqual: @"foo bar baz"] &&
(a[1] = [OFArray arrayWithObject: @"foo"]) &&
[[a[1] componentsJoinedByString: @" "] isEqual: @"foo"])
|
︙ | | |
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
-
+
|
}
} @catch (OFEnumerationMutationException *e) {
ok = YES;
}
TEST(@"Detection of mutation during Fast Enumeration", ok)
[m[0] removeNObjects: 1];
[m[0] removeLastObject];
#endif
#ifdef OF_HAVE_BLOCKS
{
__block BOOL ok = YES;
__block size_t count = 0;
OFArray *cmp = a[0];
|
︙ | | |
Modified tests/OFDataArrayTests.m
from [4d33d1b6d0]
to [742e94e327].
︙ | | |
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
-
-
+
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
-
+
-
-
-
+
+
+
-
-
+
+
-
-
-
+
+
+
+
-
+
-
+
|
TEST(@"-[count]", [array[0] count] == 2)
other = (class == [OFDataArray class]
? [OFBigDataArray class]
: [OFDataArray class]);
TEST(@"-[isEqual:]", (array[1] = [other dataArrayWithItemSize: 4096]) &&
R([array[1] addNItems: [array[0] count]
fromCArray: [array[0] cArray]]) &&
R([array[1] addItemsFromCArray: [array[0] cArray]
count: [array[0] count]]) &&
[array[1] isEqual: array[0]] &&
R([array[1] removeNItems: 1]) && ![array[0] isEqual: array[1]])
R([array[1] removeLastItem]) && ![array[0] isEqual: array[1]])
TEST(@"-[copy]", (array[1] = [[array[0] copy] autorelease]) &&
[array[0] isEqual: array[1]])
array[2] = [OFDataArray dataArray];
array[3] = [OFDataArray dataArray];
[array[2] addItem: "a"];
[array[2] addItem: "a"];
[array[3] addItem: "z"];
TEST(@"-[compare]", [array[0] compare: array[1]] == 0 &&
R([array[1] removeNItems: 1]) &&
R([array[1] removeLastItem]) &&
[array[0] compare: array[1]] == OF_ORDERED_DESCENDING &&
[array[1] compare: array[0]] == OF_ORDERED_ASCENDING &&
[array[2] compare: array[3]] == OF_ORDERED_ASCENDING)
TEST(@"-[hash]", [array[0] hash] == 0x634A529F)
array[0] = [class dataArray];
[array[0] addNItems: 6
fromCArray: "abcdef"];
[array[0] addItemsFromCArray: "abcdef"
count: 6];
TEST(@"-[removeNItems:]", R([array[0] removeNItems: 1]) &&
TEST(@"-[removeLastItem]", R([array[0] removeLastItem]) &&
[array[0] count] == 5 &&
!memcmp([array[0] cArray], "abcde", 5))
TEST(@"-[removeNItems:atIndex:]",
R([array[0] removeNItems: 2
TEST(@"-[removeItemsInRange:]",
R([array[0] removeItemsInRange: of_range(1, 2)]) &&
atIndex: 1]) && [array[0] count] == 3 &&
!memcmp([array[0] cArray], "ade", 3))
[array[0] count] == 3 && !memcmp([array[0] cArray], "ade", 3))
TEST(@"-[addNItems:atIndex:]",
TEST(@"-[insertItemsFromCArray:atIndex:count:]",
R([array[0] addNItems: 2
fromCArray: "bc"
atIndex: 1]) && [array[0] count] == 5 &&
R([array[0] insertItemsFromCArray: "bc"
atIndex: 1
count: 2]) && [array[0] count] == 5 &&
!memcmp([array[0] cArray], "abcde", 5))
TEST(@"-[MD5Hash]", [[array[0] MD5Hash] isEqual: [@"abcde" MD5Hash]])
TEST(@"-[SHA1Hash]", [[array[0] SHA1Hash] isEqual: [@"abcde" SHA1Hash]])
TEST(@"-[stringByBase64Encoding]",
[[array[0] stringByBase64Encoding] isEqual: @"YWJjZGU="])
TEST(@"+[dataArrayWithBase64EncodedString:]",
!memcmp([[class dataArrayWithBase64EncodedString: @"YWJjZGU="]
cArray], "abcde", 5))
TEST(@"Building strings",
(array[0] = [class dataArray]) &&
R([array[0] addNItems: 6
fromCArray: (void*)str]) && R([array[0] addItem: ""]) &&
R([array[0] addItemsFromCArray: (void*)str
count: 6]) && R([array[0] addItem: ""]) &&
!strcmp([array[0] cArray], str))
EXPECT_EXCEPTION(@"Detect out of range in -[itemAtIndex:]",
OFOutOfRangeException, [array[0] itemAtIndex: [array[0] count]])
EXPECT_EXCEPTION(@"Detect out of range in -[addNItems:fromCArray:]",
OFOutOfRangeException, [array[0] addNItems: SIZE_MAX
fromCArray: NULL])
EXPECT_EXCEPTION(@"Detect out of range in "
@"-[addItemsFromCArray:count:]",
OFOutOfRangeException, [array[0] addItemsFromCArray: NULL
count: SIZE_MAX])
EXPECT_EXCEPTION(@"Detect out of range in -[removeNItems:]",
EXPECT_EXCEPTION(@"Detect out of range in -[removeItemsInRange:]",
OFOutOfRangeException,
[array[0] removeNItems: [array[0] count] + 1])
[array[0] removeItemsInRange: of_range([array[0] count], 1)])
}
- (void)dataArrayTests
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
module = @"OFDataArray";
|
︙ | | |
Modified tests/OFJSONTests.m
from [b853b74aa1]
to [ae9d04304d].
︙ | | |
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
|
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
|
-
+
-
+
-
+
+
-
+
|
static OFString *module = @"OFJSON";
@implementation TestsAppDelegate (JSONTests)
- (void)JSONTests
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFString *s = @"{\"foo\"\t:\"bar\", \"x\":/*fooo*/ [7.5\r,null//bar\n"
OFString *s = @"{\"foo\"\t:'ba\\r', \"x\":/*foo*/ [.5\r,0xF,null//bar\n"
@",\"foo\",false]}";
OFDictionary *d = [OFDictionary dictionaryWithKeysAndObjects:
@"foo", @"bar",
@"foo", @"ba\r",
@"x", [OFArray arrayWithObjects:
[OFNumber numberWithFloat: 7.5f],
[OFNumber numberWithFloat: .5f],
[OFNumber numberWithInt: 0xF],
[OFNull null],
@"foo",
[OFNumber numberWithBool: NO],
nil],
nil];
TEST(@"-[JSONValue #1]", [[s JSONValue] isEqual: d])
TEST(@"-[JSONRepresentation]", [[d JSONRepresentation] isEqual:
@"{\"foo\":\"bar\",\"x\":[7.5,null,\"foo\",false]}"])
@"{\"foo\":\"ba\\r\",\"x\":[0.5,15,null,\"foo\",false]}"])
EXPECT_EXCEPTION(@"-[JSONValue #2]", OFInvalidEncodingException,
[@"{" JSONValue])
EXPECT_EXCEPTION(@"-[JSONValue #3]", OFInvalidEncodingException,
[@"]" JSONValue])
EXPECT_EXCEPTION(@"-[JSONValue #4]", OFInvalidEncodingException,
[@"bar" JSONValue])
EXPECT_EXCEPTION(@"-[JSONValue #5]", OFInvalidEncodingException,
[@"[\"a\" \"b\"]" JSONValue])
[pool drain];
}
@end
|
Modified tests/OFSerializationTests.m
from [8b60915267]
to [cf7d67e102].
︙ | | |
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
-
-
+
+
|
[l appendObject: [OFSet setWithObjects: @"foo", @"foo", @"bar", nil]];
[l appendObject:
[OFCountedSet setWithObjects: @"foo", @"foo", @"bar", nil]];
[d setObject: @"list"
forKey: l];
[da addNItems: 39
fromCArray: "0123456789:;<ABCDEFGHJIKLMNOPQRSTUVWXYZ"];
[da addItemsFromCArray: "0123456789:;<ABCDEFGHJIKLMNOPQRSTUVWXYZ"
count: 39];
[d setObject: @"data"
forKey: da];
TEST(@"-[stringBySerializing]",
(s = [d stringBySerializing]) && [s isEqual:
[OFString stringWithContentsOfFile: @"serialization.xml"]])
TEST(@"-[objectByDeserializing]",
[[s objectByDeserializing] isEqual: d])
[pool drain];
}
@end
|
Modified utils/objfw-compile
from [950c191148]
to [efa64bfec9].
︙ | | |
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
+
+
+
|
LDFLAGS="$LDFLAGS $($OBJFW_CONFIG --plugin-ldflags)"
out_suffix="$($OBJFW_CONFIG --plugin-suffix)"
;;
-pthread)
OBJCFLAGS="$OBJCFLAGS $1"
LDFLAGS="$LDFLAGS $1"
;;
-std=*)
OBJCFLAGS="$OBJCFLAGS $1"
;;
-Wl,*)
LDFLAGS="$LDFLAGS $1"
;;
-W*)
OBJCFLAGS="$OBJCFLAGS $1"
;;
-*)
|
︙ | | |