Comment: | Clean up a lot of code (mostly init methods) and fix a missing rethrow. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
8a7ca573c456f6292a26616d193db9eb |
User & Date: | js on 2010-10-25 23:03:22 |
Other Links: | manifest | tags |
2010-10-26
| ||
18:24 | Define __STDC_LIMIT_MACROS for C++ compatibility. check-in: f9316e0692 user: js tags: trunk | |
2010-10-25
| ||
23:03 | Clean up a lot of code (mostly init methods) and fix a missing rethrow. check-in: 8a7ca573c4 user: js tags: trunk | |
22:28 | Update Unicode tables. check-in: 5d3216f476 user: js tags: trunk | |
Modified src/OFApplication.m from [b4963086e3] to [c6789a7016].
︙ | ︙ | |||
87 88 89 90 91 92 93 | + (void)terminateWithStatus: (int)status { exit(status); } - init { | > > > | | < < | | | | | | | | | | | | | | | | | | | | | | > > > > | 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 136 137 138 139 140 | + (void)terminateWithStatus: (int)status { exit(status); } - init { self = [super init]; @try { OFAutoreleasePool *pool; char **env; environment = [[OFMutableDictionary alloc] init]; atexit(atexit_handler); #ifdef __MACH__ env = *_NSGetEnviron(); #else env = environ; #endif pool = [[OFAutoreleasePool alloc] init]; for (; *env != NULL; env++) { OFString *key; OFString *value; char *sep; if ((sep = strchr(*env, '=')) == NULL) { fprintf(stderr, "Warning: Invalid environment " "variable: %s\n", *env); continue; } key = [OFString stringWithCString: *env length: sep - *env]; value = [OFString stringWithCString: sep + 1]; [environment setObject: value forKey: key]; [pool releaseObjects]; } [pool release]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)setArgumentCount: (int*)argc_ andArgumentValues: (char***)argv_ { |
︙ | ︙ |
Modified src/OFArray.m from [0afd3cde8f] to [9600e51a49].
︙ | ︙ | |||
57 58 59 60 61 62 63 | - init { self = [super init]; @try { array = [[OFDataArray alloc] initWithItemSize: sizeof(id)]; | | < < < < | > | | < < < < > > | | < < < > > | | | | | < | > > | | > | | | < | > > | | 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 136 137 138 139 140 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 | - init { self = [super init]; @try { array = [[OFDataArray alloc] initWithItemSize: sizeof(id)]; } @catch (id e) { [self release]; @throw e; } return self; } - initWithObject: (id)obj { self = [self init]; @try { [array addItem: &obj]; [obj retain]; } @catch (id e) { [self release]; @throw e; } return self; } - initWithObjects: (id)first, ... { id ret; va_list args; va_start(args, first); ret = [self initWithObject: first argList: args]; va_end(args); return ret; } - initWithObject: (id)first argList: (va_list)args { self = [self init]; @try { id obj; [array addItem: &first]; while ((obj = va_arg(args, id)) != nil) { [array addItem: &obj]; [obj retain]; } } @catch (id e) { [self release]; @throw e; } return self; } - initWithCArray: (id*)objs { self = [self init]; @try { id *obj; size_t count = 0; for (obj = objs; *obj != nil; obj++) { [*obj retain]; count++; } [array addNItems: count fromCArray: objs]; } @catch (id e) { id *obj; for (obj = objs; *obj != nil; obj++) [*obj release]; [self release]; @throw e; } return self; } - initWithCArray: (id*)objs length: (size_t)len { self = [self init]; @try { size_t i; for (i = 0; i < len; i++) [objs[i] retain]; [array addNItems: len fromCArray: objs]; } @catch (id e) { size_t i; for (i = 0; i < len; i++) [objs[i] release]; [self release]; @throw e; } return self; } - (size_t)count |
︙ | ︙ |
Modified src/OFAutoreleasePool.m from [4e90c8c96d] to [2e10041b61].
︙ | ︙ | |||
44 45 46 47 48 49 50 | #ifdef OF_THREADS id last = of_tlskey_get(last_key); #endif if (last == nil) { @try { [[self alloc] init]; | | | < < < < > | | | < < | < > | | | | < < | < < | | | | | | | | < | | | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 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 | #ifdef OF_THREADS id last = of_tlskey_get(last_key); #endif if (last == nil) { @try { [[self alloc] init]; } @catch (id e) { [obj release]; @throw e; } #ifdef OF_THREADS last = of_tlskey_get(last_key); #endif } if (last == nil) { [obj release]; @throw [OFInitializationFailedException newWithClass: self]; } @try { [last addObject: obj]; } @catch (id e) { [obj release]; @throw e; } } + (void)releaseAll { #ifdef OF_THREADS [of_tlskey_get(first_key) release]; #else [first release]; #endif } - init { self = [super init]; @try { #ifdef OF_THREADS id first = of_tlskey_get(first_key); prev = of_tlskey_get(last_key); if (!of_tlskey_set(last_key, self)) @throw [OFInitializationFailedException newWithClass: isa]; #else prev = last; last = self; #endif if (first == nil) { #ifdef OF_THREADS if (!of_tlskey_set(first_key, self)) { of_tlskey_set(last_key, prev); @throw [OFInitializationFailedException newWithClass: isa]; } #else first = self; #endif } if (prev != nil) prev->next = self; size = GROW_SIZE; objects = [self allocMemoryForNItems: GROW_SIZE withSize: sizeof(id)]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)addObject: (id)obj |
︙ | ︙ |
Modified src/OFDataArray.m from [3dd22e9f84] to [e2af4c2cc3].
︙ | ︙ | |||
23 24 25 26 27 28 29 | + dataArrayWithItemSize: (size_t)is { return [[[self alloc] initWithItemSize: is] autorelease]; } - init { | > > | < < > | < < | | | < | | > > > > | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | + dataArrayWithItemSize: (size_t)is { return [[[self alloc] initWithItemSize: is] autorelease]; } - init { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithItemSize: (size_t)is { self = [super init]; @try { if (is == 0) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; data = NULL; itemSize = is; } @catch (id e) { [self release]; @throw e; } return self; } - (size_t)count { return count; |
︙ | ︙ |
Modified src/OFDictionary.m from [2b1836dbc4] to [c675091634].
︙ | ︙ | |||
63 64 65 66 67 68 69 | return ret; } - init { self = [super init]; | < < < < < < < | > > | < | > | | < < < | | | < < < < < < < < < < | < | | | | | | | < < < < | < | | | | < | | | | | > | > > > > > > > | | < < < < < < < < < < < | < | < < < < < | < | | | | < | | | | | > | | > > > > < < < > > | | | | | < < < < | < < | < | | | | | > | | | | | | | > | | | | | | | | | | | | | | > | | < < | > | < < < < < | < | | | | < | | | | | > | | | | | | | > | < < < < | < | | | | < | | | > > > > | 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 136 137 138 139 140 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 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 | return ret; } - init { self = [super init]; @try { data = [self allocMemoryWithSize: sizeof(BUCKET*)]; size = 1; data[0] = NULL; } @catch (id e) { [self release]; @throw e; } return self; } - initWithDictionary: (OFDictionary*)dict { self = [super init]; @try { uint32_t i; if (dict == nil) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; data = [self allocMemoryForNItems: dict->size withSize: sizeof(BUCKET*)]; for (i = 0; i < dict->size; i++) data[i] = NULL; size = dict->size; count = dict->count; for (i = 0; i < size; i++) { id <OFCopying> key; BUCKET *b; if (dict->data[i] == NULL || dict->data[i] == DELETED) continue; b = [self allocMemoryWithSize: sizeof(BUCKET)]; key = [dict->data[i]->key copy]; @try { [dict->data[i]->object retain]; } @catch (id e) { [(id)key release]; @throw e; } b->key = key; b->object = dict->data[i]->object; b->hash = dict->data[i]->hash; data[i] = b; } } @catch (id e) { [self release]; @throw e; } return self; } - initWithObject: (id)obj forKey: (id <OFCopying>)key { self = [super init]; @try { uint32_t i; BUCKET *b; data = [self allocMemoryForNItems: 2 withSize: sizeof(BUCKET*)]; size = 2; for (i = 0; i < size; i++) data[i] = NULL; i = [(id)key hash] & 1; b = [self allocMemoryWithSize: sizeof(BUCKET)]; key = [key copy]; @try { [obj retain]; } @catch (id e) { [(id)key release]; @throw e; } b->key = key; b->object = obj; b->hash = [(id)key hash]; data[i] = b; count = 1; } @catch (id e) { [self release]; @throw e; } return self; } - initWithObjects: (OFArray*)objs forKeys: (OFArray*)keys { self = [super init]; @try { id *objs_carray, *keys_carray; size_t i, nsize; uint32_t j; keys_carray = [keys cArray]; objs_carray = [objs cArray]; count = [keys count]; if (count > UINT32_MAX) @throw [OFOutOfRangeException newWithClass: isa]; for (nsize = 1; nsize < count; nsize <<= 1); if (nsize == 0) @throw [OFOutOfRangeException newWithClass: isa]; data = [self allocMemoryForNItems: nsize withSize: sizeof(BUCKET*)]; for (j = 0; j < nsize; j++) data[j] = NULL; size = nsize; for (i = 0; i < count; i++) { uint32_t hash, last; hash = [keys_carray[i] hash]; last = size; for (j = hash & (size - 1); j < last && data[j] != NULL; j++) if ([(id)data[j]->key isEqual: keys_carray[i]]) break; /* In case the last bucket is already used */ if (j >= last) { last = hash & (size - 1); for (j = 0; j < last && data[j] != NULL; j++) if ([(id)data[j]->key isEqual: keys_carray[i]]) break; } /* Key not in dictionary */ if (j >= last || data[j] == NULL || ![(id)data[j]->key isEqual: keys_carray[i]]) { BUCKET *b; id <OFCopying> key; last = size; j = hash & (size - 1); for (; j < last && data[j] != NULL; j++); /* In case the last bucket is already used */ if (j >= last) { last = hash & (size - 1); for (j = 0; j < last && data[j] != NULL; j++); } if (j >= last) @throw [OFOutOfRangeException newWithClass: isa]; b = [self allocMemoryWithSize: sizeof(BUCKET)]; key = [keys_carray[i] copy]; @try { [objs_carray[i] retain]; } @catch (id e) { [(id)key release]; @throw e; } b->key = key; b->object = objs_carray[i]; b->hash = hash; data[j] = b; continue; } /* * The key is already in the dictionary. However, we * just replace it so that the programmer gets the same * behavior as if he'd call setObject:forKey: for each * key/object pair. */ [objs_carray[i] retain]; @try { [data[j]->object release]; } @catch (id e) { [objs_carray[i] release]; @throw e; } data[j]->object = objs_carray[i]; } } @catch (id e) { [self release]; @throw e; } return self; } - initWithKeysAndObjects: (id <OFCopying>)first, ... { |
︙ | ︙ | |||
345 346 347 348 349 350 351 | return ret; } - initWithKey: (id <OFCopying>)key argList: (va_list)args { | > | > | | | | > > | > > > > > > > | | | | < < | | | < | < < | | < < | | < < < < < < < < | < < < | < < < < < < < < < < < | | | < < < < | < | | | | < | | | | | > | | | | | | < < | > | | < | | | > | | | | | | | | | | | | | | | | | | | > | | < < | > | < < < < < | < | | | | < | | | | | > | | | | | | | > | < < < < | < | | | | < | | | > > > > | 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 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | return ret; } - initWithKey: (id <OFCopying>)key argList: (va_list)args { self = [super init]; @try { id obj; size_t i, nsize; uint32_t j, hash; va_list args2; BUCKET *b; va_copy(args2, args); if (key == nil) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; if ((obj = va_arg(args, id)) == nil) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; count = 1; for (; va_arg(args2, id) != nil; count++); count >>= 1; if (count > UINT32_MAX) @throw [OFOutOfRangeException newWithClass: isa]; for (nsize = 1; nsize < count; nsize <<= 1); if (nsize == 0) @throw [OFOutOfRangeException newWithClass: isa]; data = [self allocMemoryForNItems: nsize withSize: sizeof(BUCKET*)]; for (j = 0; j < nsize; j++) data[j] = NULL; size = nsize; /* Add first key / object pair */ hash = [(id)key hash]; j = hash & (size - 1); b = [self allocMemoryWithSize: sizeof(BUCKET)]; key = [key copy]; @try { [obj retain]; } @catch (id e) { [(id)key release]; @throw e; } b->key = key; b->object = obj; b->hash = hash; data[j] = b; for (i = 1; i < count; i++) { uint32_t last; key = va_arg(args, id <OFCopying>); obj = va_arg(args, id); if (key == nil || obj == nil) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; hash = [(id)key hash]; last = size; for (j = hash & (size - 1); j < last && data[j] != NULL; j++) if ([(id)data[j]->key isEqual: key]) break; /* In case the last bucket is already used */ if (j >= last) { last = hash & (size - 1); for (j = 0; j < last && data[j] != NULL; j++) if ([(id)data[j]->key isEqual: key]) break; } /* Key not in dictionary */ if (j >= last || data[j] == NULL || ![(id)data[j]->key isEqual: key]) { last = size; j = hash & (size - 1); for (; j < last && data[j] != NULL; j++); /* In case the last bucket is already used */ if (j >= last) { last = hash & (size - 1); for (j = 0; j < last && data[j] != NULL; j++); } if (j >= last) @throw [OFOutOfRangeException newWithClass: isa]; b = [self allocMemoryWithSize: sizeof(BUCKET)]; key = [key copy]; @try { [obj retain]; } @catch (id e) { [(id)key release]; @throw e; } b->key = key; b->object = obj; b->hash = hash; data[j] = b; continue; } /* * The key is already in the dictionary. However, we * just replace it so that the programmer gets the same * behavior as if he'd call setObject:forKey: for each * key/object pair. */ [obj retain]; @try { [data[j]->object release]; } @catch (id e) { [obj release]; @throw e; } data[j]->object = obj; } } @catch (id e) { [self release]; @throw e; } return self; } - (id)objectForKey: (id)key { |
︙ | ︙ |
Modified src/OFEnumerator.m from [d73a03ff14] to [338aae8b92].
︙ | ︙ | |||
13 14 15 16 17 18 19 | #import "OFEnumerator.h" #import "OFExceptions.h" @implementation OFEnumerator - init { | | > > | > | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #import "OFEnumerator.h" #import "OFExceptions.h" @implementation OFEnumerator - init { if (isa == [OFEnumerator class]) { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } return [super init]; } - (id)nextObject { @throw [OFNotImplementedException newWithClass: isa |
︙ | ︙ |
Modified src/OFExceptions.m from [f32751e237] to [d710bc9531].
︙ | ︙ | |||
147 148 149 150 151 152 153 | + newWithClass: (Class)class_ { return [[self alloc] initWithClass: class_]; } - init { | > > | | 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | + newWithClass: (Class)class_ { return [[self alloc] initWithClass: class_]; } - init { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ { self = [super init]; |
︙ | ︙ | |||
249 250 251 252 253 254 255 | { return [[self alloc] initWithClass: class_ pointer: ptr]; } - initWithClass: (Class)class_ { | > > | | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | { return [[self alloc] initWithClass: class_ pointer: ptr]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ pointer: (void*)ptr { self = [super initWithClass: class_]; |
︙ | ︙ | |||
293 294 295 296 297 298 299 | { return [[self alloc] initWithClass: class_ selector: selector]; } - initWithClass: (Class)class_ { | > > | | 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | { return [[self alloc] initWithClass: class_ selector: selector]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ selector: (SEL)selector_ { self = [super initWithClass: class_]; |
︙ | ︙ | |||
348 349 350 351 352 353 354 | { return [[self alloc] initWithClass: class_ selector: selector_]; } - initWithClass: (Class)class_ { | > > | | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 | { return [[self alloc] initWithClass: class_ selector: selector_]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ selector: (SEL)selector_ { self = [super initWithClass: class_]; |
︙ | ︙ | |||
445 446 447 448 449 450 451 | return [(OFOpenFileFailedException*)[self alloc] initWithClass: class_ path: path mode: mode]; } - initWithClass: (Class)class_ { | > > | > | | | > > > > | 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 | return [(OFOpenFileFailedException*)[self alloc] initWithClass: class_ path: path mode: mode]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ path: (OFString*)path_ mode: (OFString*)mode_ { self = [super initWithClass: class_]; @try { path = [path_ copy]; mode = [mode_ copy]; errNo = GET_ERRNO; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [path release]; |
︙ | ︙ | |||
508 509 510 511 512 513 514 | { return [[self alloc] initWithClass: class_ size: size]; } - initWithClass: (Class)class_ { | > > | | 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 | { return [[self alloc] initWithClass: class_ size: size]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ size: (size_t)size { self = [super initWithClass: class_]; |
︙ | ︙ | |||
604 605 606 607 608 609 610 | { return [[self alloc] initWithClass: class_ path: path_]; } - initWithClass: (Class)class_ { | > > | > | | > > > > | 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 | { return [[self alloc] initWithClass: class_ path: path_]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ path: (OFString*)path_ { self = [super initWithClass: class_]; @try { path = [path_ copy]; errNo = GET_ERRNO; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [path release]; |
︙ | ︙ | |||
662 663 664 665 666 667 668 | initWithClass: class_ path: path mode: mode]; } - initWithClass: (Class)class_ { | > > | > | | | > > > > | 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 | initWithClass: class_ path: path mode: mode]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ path: (OFString*)path_ mode: (mode_t)mode_ { self = [super initWithClass: class_]; @try { path = [path_ copy]; mode = mode_; errNo = GET_ERRNO; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [path release]; |
︙ | ︙ | |||
729 730 731 732 733 734 735 | path: path owner: owner group: group]; } - initWithClass: (Class)class_ { | > > | > | | | | > > > > | 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 | path: path owner: owner group: group]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ path: (OFString*)path_ owner: (uid_t)owner_ group: (gid_t)group_ { self = [super initWithClass: class_]; @try { path = [path_ copy]; owner = owner_; group = group_; errNo = GET_ERRNO; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [path release]; |
︙ | ︙ | |||
801 802 803 804 805 806 807 | return [[self alloc] initWithClass: class_ sourcePath: src destinationPath: dst]; } - initWithClass: (Class)class_ { | > > | > | | | > > > > | 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 866 867 868 869 870 871 872 | return [[self alloc] initWithClass: class_ sourcePath: src destinationPath: dst]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ sourcePath: (OFString*)src destinationPath: (OFString*)dst { self = [super initWithClass: class_]; @try { sourcePath = [src copy]; destinationPath = [dst copy]; errNo = GET_ERRNO; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [sourcePath release]; |
︙ | ︙ | |||
867 868 869 870 871 872 873 | return [[self alloc] initWithClass: class_ sourcePath: src destinationPath: dst]; } - initWithClass: (Class)class_ { | > > | > | | | > > > > | 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 | return [[self alloc] initWithClass: class_ sourcePath: src destinationPath: dst]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ sourcePath: (OFString*)src destinationPath: (OFString*)dst { self = [super initWithClass: class_]; @try { sourcePath = [src copy]; destinationPath = [dst copy]; errNo = GET_ERRNO; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [sourcePath release]; |
︙ | ︙ | |||
931 932 933 934 935 936 937 | { return [[self alloc] initWithClass: class_ path: path_]; } - initWithClass: (Class)class_ { | > > | > | | > > > > | 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 | { return [[self alloc] initWithClass: class_ path: path_]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ path: (OFString*)path_ { self = [super initWithClass: class_]; @try { path = [path_ copy]; errNo = GET_ERRNO; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [path release]; |
︙ | ︙ | |||
986 987 988 989 990 991 992 | { return [[self alloc] initWithClass: class_ path: path_]; } - initWithClass: (Class)class_ { | > > | > | | > > > > | 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 | { return [[self alloc] initWithClass: class_ path: path_]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ path: (OFString*)path_ { self = [super initWithClass: class_]; @try { path = [path_ copy]; errNo = GET_ERRNO; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [path release]; |
︙ | ︙ | |||
1044 1045 1046 1047 1048 1049 1050 | return [[self alloc] initWithClass: class_ sourcePath: src destinationPath: dest]; } - initWithClass: (Class)class_ { | > > | | 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 | return [[self alloc] initWithClass: class_ sourcePath: src destinationPath: dest]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ sourcePath: (OFString*)src destinationPath: (OFString*)dest { |
︙ | ︙ | |||
1110 1111 1112 1113 1114 1115 1116 | return [[self alloc] initWithClass: class_ sourcePath: src destinationPath: dest]; } - initWithClass: (Class)class_ { | > > | | 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 | return [[self alloc] initWithClass: class_ sourcePath: src destinationPath: dest]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ sourcePath: (OFString*)src destinationPath: (OFString*)dest { |
︙ | ︙ | |||
1231 1232 1233 1234 1235 1236 1237 | - initWithClass: (Class)class_ node: (OFString*)node_ service: (OFString*)service_ { self = [super initWithClass: class_]; | > | | | > > > > | 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 | - initWithClass: (Class)class_ node: (OFString*)node_ service: (OFString*)service_ { self = [super initWithClass: class_]; @try { node = [node_ copy]; service = [service_ copy]; errNo = GET_AT_ERRNO; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [node release]; |
︙ | ︙ | |||
1296 1297 1298 1299 1300 1301 1302 | return [[self alloc] initWithClass: class_ node: node service: service]; } - initWithClass: (Class)class_ { | > > | > | | | > > > > | 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 | return [[self alloc] initWithClass: class_ node: node service: service]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ node: (OFString*)node_ service: (OFString*)service_ { self = [super initWithClass: class_]; @try { node = [node_ copy]; service = [service_ copy]; errNo = GET_SOCK_ERRNO; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [node release]; |
︙ | ︙ | |||
1364 1365 1366 1367 1368 1369 1370 | node: node service: service family: family]; } - initWithClass: (Class)class_ { | > > | > | | | | > > > > | 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 | node: node service: service family: family]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ node: (OFString*)node_ service: (OFString*)service_ family: (int)family_ { self = [super initWithClass: class_]; @try { node = [node_ copy]; service = [service_ copy]; family = family_; errNo = GET_SOCK_ERRNO; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [node release]; |
︙ | ︙ | |||
1435 1436 1437 1438 1439 1440 1441 | { return [[self alloc] initWithClass: class_ backLog: backlog]; } - initWithClass: (Class)class_ { | > > | | 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 | { return [[self alloc] initWithClass: class_ backLog: backlog]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ backLog: (int)backlog { self = [super initWithClass: class_]; |
︙ | ︙ | |||
1599 1600 1601 1602 1603 1604 1605 | { return [[self alloc] initWithClass: class_ prefix: prefix]; } - initWithClass: (Class)class_ { | > > | > | > > > > > | > > > > | 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 | { return [[self alloc] initWithClass: class_ prefix: prefix]; } - initWithClass: (Class)class_ { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithClass: (Class)class_ namespace: (OFString*)ns_ { self = [super initWithClass: class_]; @try { ns = [ns_ copy]; } @catch (id e) { [self release]; @throw e; } return self; } - initWithClass: (Class)class_ prefix: (OFString*)prefix_ { self = [super initWithClass: class_]; @try { prefix = [prefix_ copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [ns release]; |
︙ | ︙ |
Modified src/OFFile.m from [9c2025e097] to [d06bb2b5c9].
︙ | ︙ | |||
412 413 414 415 416 417 418 | sourcePath: src destinationPath: dest]; } #endif - init { | > > | > | > | < < | < < | | | < | < < | | | | < | > > > > | 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 | sourcePath: src destinationPath: dest]; } #endif - init { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithPath: (OFString*)path mode: (OFString*)mode { self = [super init]; @try { int flags; if ((flags = parse_mode([mode cString])) == -1) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; if ((fd = open([path cString], flags, DEFAULT_MODE)) == -1) @throw [OFOpenFileFailedException newWithClass: isa path: path mode: mode]; closable = YES; } @catch (id e) { [self release]; @throw e; } return self; } - initWithFileDescriptor: (int)fd_ { self = [super init]; |
︙ | ︙ | |||
539 540 541 542 543 544 545 | @end /// \cond internal @implementation OFFileSingleton - initWithPath: (OFString*)path mode: (OFString*)mode { | > > | | 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 | @end /// \cond internal @implementation OFFileSingleton - initWithPath: (OFString*)path mode: (OFString*)mode { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - autorelease { return self; } |
︙ | ︙ |
Modified src/OFList.m from [79d7008d03] to [39a49b7b3f].
︙ | ︙ | |||
222 223 224 225 226 227 228 | new->count++; [o->object retain]; prev = o; } | | | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | new->count++; [o->object retain]; prev = o; } } @catch (id e) { [new release]; @throw e; } new->lastListObject = o; return new; |
︙ | ︙ |
Modified src/OFMutableDictionary.m from [078edcac44] to [0596555fcb].
︙ | ︙ | |||
137 138 139 140 141 142 143 | if (i >= last) @throw [OFOutOfRangeException newWithClass: isa]; b = [self allocMemoryWithSize: sizeof(BUCKET)]; @try { key = [key copy]; | | > | | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | if (i >= last) @throw [OFOutOfRangeException newWithClass: isa]; b = [self allocMemoryWithSize: sizeof(BUCKET)]; @try { key = [key copy]; } @catch (id e) { [self freeMemory: b]; @throw e; } @try { [obj retain]; } @catch (id e) { [self freeMemory: b]; [(id)key release]; @throw e; } b->key = key; b->object = obj; |
︙ | ︙ |
Modified src/OFMutableString.m from [a7c6aaf7d8] to [21aaad94ff].
︙ | ︙ | |||
92 93 94 95 96 97 98 | } i += clen; } @try { nstr = [self allocMemoryWithSize: nlen + 1]; | | | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | } i += clen; } @try { nstr = [self allocMemoryWithSize: nlen + 1]; } @catch (id e) { [self freeMemory: ustr]; @throw e; } j = 0; for (i = 0; i < ulen; i++) { |
︙ | ︙ | |||
468 469 470 471 472 473 474 | if (memcmp(string + i, str_c, str_len)) continue; @try { tmp = [self resizeMemory: tmp toSize: tmp_len + i - last + repl_len + 1]; | | | | 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | if (memcmp(string + i, str_c, str_len)) continue; @try { tmp = [self resizeMemory: tmp toSize: tmp_len + i - last + repl_len + 1]; } @catch (id e) { [self freeMemory: tmp]; @throw e; } memcpy(tmp + tmp_len, string + last, i - last); memcpy(tmp + tmp_len + i - last, repl_c, repl_len); tmp_len += i - last + repl_len; i += str_len - 1; last = i + 1; } @try { tmp = [self resizeMemory: tmp toSize: tmp_len + length - last + 1]; } @catch (id e) { [self freeMemory: tmp]; @throw e; } memcpy(tmp + tmp_len, string + last, length - last); tmp_len += length - last; tmp[tmp_len] = 0; |
︙ | ︙ |
Modified src/OFPlugin.m from [510d0be2d3] to [0c901eacaf].
︙ | ︙ | |||
55 56 57 58 59 60 61 | plugin->handle = handle; return plugin; } - init { | | > > | > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | plugin->handle = handle; return plugin; } - init { if (isa == [OFPlugin class]) { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } return [super init]; } - (void)dealloc { dlclose(handle); [super dealloc]; } @end |
Modified src/OFStream.m from [712dcb6dbd] to [9e9b9829fb].
︙ | ︙ | |||
26 27 28 29 30 31 32 | #import "macros.h" #import "asprintf.h" @implementation OFStream - init { | < < | > > | > > > | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #import "macros.h" #import "asprintf.h" @implementation OFStream - init { if (isa == [OFStream class]) { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } self = [super init]; cache = NULL; wBuffer = NULL; return self; } |
︙ | ︙ | |||
312 313 314 315 316 317 318 | ret_len--; @try { ret = [OFString stringWithCString: ret_c encoding: encoding length: ret_len]; | | | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | ret_len--; @try { ret = [OFString stringWithCString: ret_c encoding: encoding length: ret_len]; } @catch (id e) { /* * Append data to cache to * prevent loss of data due to * wrong encoding. */ cache = [self resizeMemory: cache |
︙ | ︙ |
Modified src/OFStreamObserver.m from [3a6498e60a] to [269a665b2b].
︙ | ︙ | |||
43 44 45 46 47 48 49 | fds = [[OFDataArray alloc] initWithItemSize: sizeof(struct pollfd)]; fdToStream = [[OFMutableDictionary alloc] init]; #else FD_ZERO(&readfds); FD_ZERO(&writefds); #endif | | | | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | fds = [[OFDataArray alloc] initWithItemSize: sizeof(struct pollfd)]; fdToStream = [[OFMutableDictionary alloc] init]; #else FD_ZERO(&readfds); FD_ZERO(&writefds); #endif } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc |
︙ | ︙ |
Modified src/OFString.h from [5350934922] to [3ca2bba748].
︙ | ︙ | |||
131 132 133 134 135 136 137 | * \param path The path to the file * \param encoding The encoding of the file * \return A new autoreleased OFString */ + stringWithContentsOfFile: (OFString*)path encoding: (enum of_string_encoding)encoding; | < < < < < < < | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | * \param path The path to the file * \param encoding The encoding of the file * \return A new autoreleased OFString */ + stringWithContentsOfFile: (OFString*)path encoding: (enum of_string_encoding)encoding; /** * Initializes an already allocated OFString from a UTF-8 encoded C string. * * \param str A UTF-8 encoded C string to initialize the OFString with * \return An initialized OFString */ - initWithCString: (const char*)str; |
︙ | ︙ |
Modified src/OFString.m from [2546d1519d] to [6583af04e3].
︙ | ︙ | |||
298 299 300 301 302 303 304 | + stringWithContentsOfFile: (OFString*)path encoding: (enum of_string_encoding)encoding { return [[[self alloc] initWithContentsOfFile: path encoding: encoding] autorelease]; } | < < < < < < < < < < < > > | < | < < < < < < < | | < < | | | | | | < < < < < < < | > | | | | > | | < | > > > | | | < < < | | < | < < | < < | | < < < < < < < | < | > > > > > > > > > > | > | | > > > > > > > > > > | < > | > > | > > | > | | | > | | | < | | | < < < < < < < < | | | < | < | | < < < < < < < < < < | < | | | | < | < < < < < < < < | | | 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 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 | + stringWithContentsOfFile: (OFString*)path encoding: (enum of_string_encoding)encoding { return [[[self alloc] initWithContentsOfFile: path encoding: encoding] autorelease]; } - initWithCString: (const char*)str { return [self initWithCString: str encoding: OF_STRING_ENCODING_UTF_8 length: strlen(str)]; } - initWithCString: (const char*)str encoding: (enum of_string_encoding)encoding { return [self initWithCString: str encoding: encoding length: strlen(str)]; } - initWithCString: (const char*)str encoding: (enum of_string_encoding)encoding length: (size_t)len { self = [super init]; @try { size_t i, j; const uint16_t *table; string = [self allocMemoryWithSize: len + 1]; length = len; if (encoding == OF_STRING_ENCODING_UTF_8) { switch (of_string_check_utf8(str, length)) { case 1: isUTF8 = YES; break; case -1: @throw [OFInvalidEncodingException newWithClass: isa]; } memcpy(string, str, length); string[length] = 0; return self; } if (encoding == OF_STRING_ENCODING_ISO_8859_1) { for (i = j = 0; i < len; i++) { char buf[4]; size_t bytes; if (!(str[i] & 0x80)) { string[j++] = str[i]; continue; } isUTF8 = YES; bytes = of_string_unicode_to_utf8( (uint8_t)str[i], buf); if (bytes == 0) @throw [OFInvalidEncodingException newWithClass: isa]; length += bytes - 1; string = [self resizeMemory: string toSize: length + 1]; memcpy(string + j, buf, bytes); j += bytes; } string[length] = 0; return self; } switch (encoding) { case OF_STRING_ENCODING_ISO_8859_15: table = of_iso_8859_15; break; case OF_STRING_ENCODING_WINDOWS_1252: table = of_windows_1252; break; default: @throw [OFInvalidEncodingException newWithClass: isa]; } for (i = j = 0; i < len; i++) { char buf[4]; of_unichar_t chr; size_t chr_bytes; if (!(str[i] & 0x80)) { string[j++] = str[i]; continue; } chr = table[(uint8_t)str[i]]; if (chr == 0xFFFD) @throw [OFInvalidEncodingException newWithClass: isa]; isUTF8 = YES; chr_bytes = of_string_unicode_to_utf8(chr, buf); if (chr_bytes == 0) @throw [OFInvalidEncodingException newWithClass: isa]; length += chr_bytes - 1; string = [self resizeMemory: string toSize: length + 1]; memcpy(string + j, buf, chr_bytes); j += chr_bytes; } string[length] = 0; } @catch (id e) { [self release]; @throw e; } return self; } - initWithCString: (const char*)str length: (size_t)len |
︙ | ︙ | |||
490 491 492 493 494 495 496 | return ret; } - initWithFormat: (OFString*)fmt arguments: (va_list)args { | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > > > > > > > > > > > > > > > > > > > > > > > > > > | | | > > > | 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 488 489 490 491 492 493 494 495 496 | return ret; } - initWithFormat: (OFString*)fmt arguments: (va_list)args { self = [super init]; @try { int t; if (fmt == nil) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; if ((t = vasprintf(&string, [fmt cString], args)) == -1) /* * This is only the most likely error to happen. * Unfortunately, there is no good way to check what * really happened. */ @throw [OFOutOfMemoryException newWithClass: isa]; @try { length = t; switch (of_string_check_utf8(string, length)) { case 1: isUTF8 = YES; break; case -1: @throw [OFInvalidEncodingException newWithClass: isa]; } [self addMemoryToPool: string]; } @catch (id e) { free(string); } } @catch (id e) { [self release]; @throw e; } return self; } - initWithPath: (OFString*)first, ... |
︙ | ︙ | |||
550 551 552 553 554 555 556 | return ret; } - initWithPath: (OFString*)first arguments: (va_list)args { | > > > | | | < | < | | | | | < < | | < > | | | | | > | | | | < < | > | | < < < < < | | | | | | | | | | > > > > > > | | | | | | | < < | | | < < | | > | < | | | < < < < < | > > > | > > > > | | | | < < | < < < < < | < | | < | | < < < < < < | < < | > | > > > > | 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 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 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 643 644 645 646 647 | return ret; } - initWithPath: (OFString*)first arguments: (va_list)args { self = [super init]; @try { OFString *component; size_t len, i; va_list args2; length = [first cStringLength]; switch (of_string_check_utf8([first cString], length)) { case 1: isUTF8 = YES; break; case -1: @throw [OFInvalidEncodingException newWithClass: isa]; } /* Calculate length */ va_copy(args2, args); while ((component = va_arg(args2, OFString*)) != nil) { len = [component cStringLength]; length += 1 + len; switch (of_string_check_utf8([component cString], len)) { case 1: isUTF8 = YES; break; case -1: @throw [OFInvalidEncodingException newWithClass: isa]; } } string = [self allocMemoryWithSize: length + 1]; len = [first cStringLength]; memcpy(string, [first cString], len); i = len; while ((component = va_arg(args, OFString*)) != nil) { len = [component cStringLength]; string[i] = OF_PATH_DELIM; memcpy(string + i + 1, [component cString], len); i += len + 1; } string[i] = '\0'; } @catch (id e) { [self release]; @throw e; } return self; } - initWithString: (OFString*)str { self = [super init]; @try { /* We have no -[dealloc], so this is ok */ string = (char*)[str cString]; length = [str cStringLength]; switch (of_string_check_utf8(string, length)) { case 1: isUTF8 = YES; break; case -1:; @throw [OFInvalidEncodingException newWithClass: isa]; } if ((string = strdup(string)) == NULL) @throw [OFOutOfMemoryException newWithClass: isa size: length + 1]; @try { [self addMemoryToPool: string]; } @catch (id e) { free(string); @throw e; } } @catch (id e) { [self release]; @throw e; } return self; } - initWithContentsOfFile: (OFString*)path { return [self initWithContentsOfFile: path encoding: OF_STRING_ENCODING_UTF_8]; } - initWithContentsOfFile: (OFString*)path encoding: (enum of_string_encoding)encoding { self = [super init]; @try { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFFile *file; char *tmp; struct stat s; if (stat([path cString], &s) == -1) @throw [OFInitializationFailedException newWithClass: isa]; tmp = [self allocMemoryWithSize: s.st_size]; file = [OFFile fileWithPath: path mode: @"rb"]; [file readExactlyNBytes: s.st_size intoBuffer: tmp]; self = [self initWithCString: tmp encoding: encoding length: s.st_size]; [self freeMemory: tmp]; [pool release]; } @catch (id e) { [self release]; @throw e; } return self; } - (const char*)cString { |
︙ | ︙ |
Modified src/OFTCPSocket.m from [9e5de8c85a] to [fc8eae7a7b].
︙ | ︙ | |||
154 155 156 157 158 159 160 | # ifdef OF_THREADS @try { for (ip = he->h_addr_list; *ip != NULL; ip++) [addrlist addItem: ip]; /* Add the terminating NULL */ [addrlist addItem: ip]; | | | 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | # ifdef OF_THREADS @try { for (ip = he->h_addr_list; *ip != NULL; ip++) [addrlist addItem: ip]; /* Add the terminating NULL */ [addrlist addItem: ip]; } @catch (id e) { [addrlist release]; @throw e; } @finally { [mutex unlock]; } for (ip = [addrlist cArray]; *ip != NULL; ip++) { |
︙ | ︙ | |||
342 343 344 345 346 347 348 | int s; newsock = [OFTCPSocket socket]; addrlen = sizeof(struct sockaddr); @try { addr = [newsock allocMemoryWithSize: sizeof(struct sockaddr)]; | | | 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | int s; newsock = [OFTCPSocket socket]; addrlen = sizeof(struct sockaddr); @try { addr = [newsock allocMemoryWithSize: sizeof(struct sockaddr)]; } @catch (id e) { [newsock dealloc]; @throw e; } if ((s = accept(sock, addr, &addrlen)) == INVALID_SOCKET) { [newsock dealloc]; @throw [OFAcceptFailedException newWithClass: isa]; |
︙ | ︙ |
Modified src/OFThread.m from [4035170a3e] to [6d911d6e5b].
︙ | ︙ | |||
131 132 133 134 135 136 137 | [thread release]; of_thread_exit(); } - init { | > > | > | > > > > | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | [thread release]; of_thread_exit(); } - init { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithObject: (id)obj { self = [super init]; @try { object = [obj retain]; } @catch (id e) { [self release]; @throw e; } return self; } - (id)main { @throw [OFNotImplementedException newWithClass: isa |
︙ | ︙ | |||
225 226 227 228 229 230 231 | } } - init { self = [super init]; | > | < < | > | < | | < > | < < < < < < | | < | 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 | } } - init { self = [super init]; @try { if (!of_tlskey_new(&key)) @throw [OFInitializationFailedException newWithClass: isa]; destructor = NULL; @synchronized (tlskeys) { listobj = [tlskeys appendObject: self]; } } @catch (id e) { [self release]; @throw e; } return self; } - initWithDestructor: (void(*)(id))destructor_ { |
︙ | ︙ | |||
267 268 269 270 271 272 273 | - (void)dealloc { if (destructor != NULL) destructor(self); of_tlskey_free(key); | < | | > > | | 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 | - (void)dealloc { if (destructor != NULL) destructor(self); of_tlskey_free(key); /* In case we called [self release] in init */ if (listobj != NULL) { @synchronized (tlskeys) { [tlskeys removeListObject: listobj]; } } [super dealloc]; } @end @implementation OFMutex + mutex { return [[[self alloc] init] autorelease]; } - init { self = [super init]; if (!of_mutex_new(&mutex)) { Class c = isa; [self release]; @throw [OFInitializationFailedException newWithClass: c]; } return self; } - (void)lock |
︙ | ︙ |
Modified src/OFXMLAttribute.m from [2b47f3dee2] to [beaa9ae3cf].
︙ | ︙ | |||
27 28 29 30 31 32 33 | - initWithName: (OFString*)name_ namespace: (OFString*)ns_ stringValue: (OFString*)value { self = [super init]; | > | | | > > > > | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | - initWithName: (OFString*)name_ namespace: (OFString*)ns_ stringValue: (OFString*)value { self = [super init]; @try { name = [name_ copy]; ns = [ns_ copy]; stringValue = [value copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [name release]; |
︙ | ︙ |
Modified src/OFXMLElement.m from [e59c8082fb] to [4e57f733e3].
︙ | ︙ | |||
64 65 66 67 68 69 70 | + elementWithComment: (OFString*)comment { return [[[self alloc] initWithComment: comment] autorelease]; } - init { | > > | | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | + elementWithComment: (OFString*)comment { return [[[self alloc] initWithComment: comment] autorelease]; } - init { Class c = isa; [self release]; @throw [OFNotImplementedException newWithClass: c selector: _cmd]; } - initWithName: (OFString*)name_ { return [self initWithName: name_ namespace: nil |
︙ | ︙ | |||
97 98 99 100 101 102 103 | - initWithName: (OFString*)name_ namespace: (OFString*)ns_ stringValue: (OFString*)stringval { self = [super init]; | > | | | > > | | | | | | > | | > > > > > | > > > > > | > > > > > | > > > > | 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 136 137 138 139 140 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 | - initWithName: (OFString*)name_ namespace: (OFString*)ns_ stringValue: (OFString*)stringval { self = [super init]; @try { name = [name_ copy]; ns = [ns_ copy]; if (stringval != nil) { OFAutoreleasePool *pool; pool = [[OFAutoreleasePool alloc] init];; [self addChild: [OFXMLElement elementWithCharacters: stringval]]; [pool release]; } namespaces = [[OFMutableDictionary alloc] initWithKeysAndObjects: @"http://www.w3.org/XML/1998/namespace", @"xml", @"http://www.w3.org/2000/xmlns/", @"xmlns", nil]; } @catch (id e) { [self release]; @throw e; } return self; } - initWithCharacters: (OFString*)chars { self = [super init]; @try { characters = [chars copy]; } @catch (id e) { [self release]; @throw e; } return self; } - initWithCDATA: (OFString*)cdata_ { self = [super init]; @try { cdata = [cdata_ copy]; } @catch (id e) { [self release]; @throw e; } return self; } - initWithComment: (OFString*)comment_ { self = [super init]; @try { comment = [comment_ copy]; } @catch (id e) { [self release]; @throw e; } return self; } - (OFString*)name { return [[name copy] autorelease]; |
︙ | ︙ | |||
225 226 227 228 229 230 231 | (ns != nil ? ns : (OFString*)@"")]) == nil) @throw [OFUnboundNamespaceException newWithClass: isa namespace: ns]; len += [prefix cStringLength] + 1; @try { str_c = [self resizeMemory: str_c toSize: len]; | | | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | (ns != nil ? ns : (OFString*)@"")]) == nil) @throw [OFUnboundNamespaceException newWithClass: isa namespace: ns]; len += [prefix cStringLength] + 1; @try { str_c = [self resizeMemory: str_c toSize: len]; } @catch (id e) { [self freeMemory: str_c]; @throw e; } memcpy(str_c + i, [prefix cString], [prefix cStringLength]); i += [prefix cStringLength]; |
︙ | ︙ | |||
263 264 265 266 267 268 269 | len += [attr_name cStringLength] + (attr_prefix != nil ? [attr_prefix cStringLength] + 1 : 0) + [tmp cStringLength] + 4; @try { str_c = [self resizeMemory: str_c toSize: len]; | | | 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | len += [attr_name cStringLength] + (attr_prefix != nil ? [attr_prefix cStringLength] + 1 : 0) + [tmp cStringLength] + 4; @try { str_c = [self resizeMemory: str_c toSize: len]; } @catch (id e) { [self freeMemory: str_c]; @throw e; } str_c[i++] = ' '; if (attr_prefix != nil) { memcpy(str_c + i, [attr_prefix cString], |
︙ | ︙ | |||
308 309 310 311 312 313 314 | _stringWithParentNamespaces: all_namespaces parentDefaultNamespace: defaultNamespace] cString]); len += [tmp cStringLength] + [name cStringLength] + 2; @try { str_c = [self resizeMemory: str_c toSize: len]; | | | | 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 | _stringWithParentNamespaces: all_namespaces parentDefaultNamespace: defaultNamespace] cString]); len += [tmp cStringLength] + [name cStringLength] + 2; @try { str_c = [self resizeMemory: str_c toSize: len]; } @catch (id e) { [self freeMemory: str_c]; @throw e; } str_c[i++] = '>'; memcpy(str_c + i, [tmp cString], [tmp cStringLength]); i += [tmp cStringLength]; str_c[i++] = '<'; str_c[i++] = '/'; if (prefix != nil) { len += [prefix cStringLength] + 1; @try { str_c = [self resizeMemory: str_c toSize: len]; } @catch (id e) { [self freeMemory: str_c]; @throw e; } memcpy(str_c + i, [prefix cString], [prefix cStringLength]); i += [prefix cStringLength]; |
︙ | ︙ |
Modified src/OFXMLElementBuilder.m from [59069a8174] to [eabccc3dd1].
︙ | ︙ | |||
23 24 25 26 27 28 29 | return [[[self alloc] init] autorelease]; } - init { self = [super init]; | > | > > > > | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | return [[[self alloc] init] autorelease]; } - init { self = [super init]; @try { stack = [[OFMutableArray alloc] init]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { [stack release]; |
︙ | ︙ |
Modified src/OFXMLParser.m from [38257f6427] to [54f1adaa82].
︙ | ︙ | |||
140 141 142 143 144 145 146 | pool = [[OFAutoreleasePool alloc] init]; dict = [OFMutableDictionary dictionaryWithKeysAndObjects: @"xml", @"http://www.w3.org/XML/1998/namespace", @"xmlns", @"http://www.w3.org/2000/xmlns/", nil]; [namespaces addObject: dict]; [pool release]; | | | | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | pool = [[OFAutoreleasePool alloc] init]; dict = [OFMutableDictionary dictionaryWithKeysAndObjects: @"xml", @"http://www.w3.org/XML/1998/namespace", @"xmlns", @"http://www.w3.org/2000/xmlns/", nil]; [namespaces addObject: dict]; [pool release]; } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc |
︙ | ︙ |