Comment: | Adjust API to introduction of OFAutoreleasePool. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
1496808b81a73a46e23cdac480ef26f8 |
User & Date: | js on 2009-01-24 15:24:49 |
Other Links: | manifest | tags |
2009-01-24
| ||
15:33 | Remove now useless release calls. check-in: e635b9a3fc user: js tags: trunk | |
15:24 | Adjust API to introduction of OFAutoreleasePool. check-in: 1496808b81 user: js tags: trunk | |
2009-01-20
| ||
14:53 |
Fix a bug causing an exception when autorelease was requested. This happened when the last pool was released before. check-in: cb9fd1e5dd user: js tags: trunk | |
Modified src/OFArray.h from [e7a8933e40] to [0b607ebca5].
︙ | ︙ | |||
23 24 25 26 27 28 29 | size_t items; } /** * Creates a new OFArray whose items all have the same size. * * \param is The size of each element in the OFArray | | | > > > > > > > > > | 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 | size_t items; } /** * Creates a new OFArray whose items all have the same size. * * \param is The size of each element in the OFArray * \return A new autoreleased OFArray */ + arrayWithItemSize: (size_t)is; /* * Creates a new OFArray optimized for big arrays whose items all have the same * size, which means memory is allocated in pages rather than in bytes. * * \param is The size of each element in the OFArray * \return A new autoreleased OFArray */ + bigArrayWithItemSize: (size_t)is; /** * Initializes an already allocated OFArray whose items all have the same size. * * \param is The size of each element in the OFArray * \return An initialized OFArray */ |
︙ | ︙ | |||
87 88 89 90 91 92 93 | * Removes a specified amount of the last items from the OFArray. * * \param nitems The number of items to remove */ - removeNItems: (size_t)nitems; @end | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | * Removes a specified amount of the last items from the OFArray. * * \param nitems The number of items to remove */ - removeNItems: (size_t)nitems; @end @interface OFBigArray: OFArray { size_t size; } - initWithItemSize: (size_t)is; - add: (void*)item; - addNItems: (size_t)nitems fromCArray: (void*)carray; - removeNItems: (size_t)nitems; @end |
Modified src/OFArray.m from [5b2194bc15] to [ea5c3825ad].
︙ | ︙ | |||
20 21 22 23 24 25 26 | #import "OFExceptions.h" #import "OFMacros.h" static size_t lastpagebyte = 0; extern int getpagesize(void); @implementation OFArray | | | > > > > > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #import "OFExceptions.h" #import "OFMacros.h" static size_t lastpagebyte = 0; extern int getpagesize(void); @implementation OFArray + arrayWithItemSize: (size_t)is { return [[[self alloc] initWithItemSize: is] autorelease]; } + bigArrayWithItemSize: (size_t)is { return [[[OFBigArray alloc] initWithItemSize: is] autorelease]; } - initWithItemSize: (size_t)is { if ((self = [super init])) { data = NULL; itemsize = is; |
︙ | ︙ |
Modified src/OFAutoreleasePool.m from [53c2a094cf] to [6b8df1f839].
︙ | ︙ | |||
105 106 107 108 109 110 111 | return [super free]; } - addToPool: (OFObject*)obj { if (objects == nil) | | | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | return [super free]; } - addToPool: (OFObject*)obj { if (objects == nil) objects = [[OFArray alloc] initWithItemSize: sizeof(char*)]; [objects add: &obj]; return self; } - release |
︙ | ︙ |
Modified src/OFExceptions.h from [5b59b73e4f] to [fb7bdc037c].
︙ | ︙ | |||
9 10 11 12 13 14 15 16 17 18 19 20 21 22 | * the packaging of this file. */ #import "OFObject.h" /** * The OFException class is the base class for all exceptions in ObjFW. */ @interface OFException: OFObject { Class class; char *string; } | > > | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | * the packaging of this file. */ #import "OFObject.h" /** * The OFException class is the base class for all exceptions in ObjFW. * * IMPORTANT: Exceptions do NOT use OFAutoreleasePools!! */ @interface OFException: OFObject { Class class; char *string; } |
︙ | ︙ |
Modified src/OFFile.h from [c444256949] to [75dce3944f].
︙ | ︙ | |||
28 29 30 31 32 33 34 | { FILE *fp; } /** * \param path The path to the file to open as a C string * \param mode The mode in which the file should be opened as a C string | | | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | { FILE *fp; } /** * \param path The path to the file to open as a C string * \param mode The mode in which the file should be opened as a C string * \return A new autoreleased OFFile */ + fileWithPath: (const char*)path andMode: (const char*)mode; /** * Changes the mode of a file. * * Not available on Windows. * * \param path The path to the file of which the mode should be changed as a * C string |
︙ | ︙ |
Modified src/OFFile.m from [3489cc9954] to [f8ec01874b].
︙ | ︙ | |||
20 21 22 23 24 25 26 | #import <sys/stat.h> #endif #import "OFFile.h" #import "OFExceptions.h" @implementation OFFile | | | | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #import <sys/stat.h> #endif #import "OFFile.h" #import "OFExceptions.h" @implementation OFFile + fileWithPath: (const char*)path andMode: (const char*)mode { return [[[self alloc] initWithPath: path andMode: mode] autorelease]; } + (void)changeModeOfFile: (const char*)path toMode: (mode_t)mode { /* * FIXME: On error, throw exception |
︙ | ︙ | |||
179 180 181 182 183 184 185 186 | - (size_t)writeCString: (const char*)str { return [self writeNItems: strlen(str) ofSize: 1 fromBuffer: (const uint8_t*)str]; } @end | > > > > > > > > | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | - (size_t)writeCString: (const char*)str { return [self writeNItems: strlen(str) ofSize: 1 fromBuffer: (const uint8_t*)str]; } - close { fclose(fp); fp = NULL; return self; } @end |
Modified src/OFHashes.h from [69af6f5e0e] to [d9a99aea79].
︙ | ︙ | |||
22 23 24 25 26 27 28 29 30 31 32 33 34 35 | uint32_t buf[4]; uint32_t bits[2]; uint8_t in[64]; BOOL calculated; } - init; /** * Adds a buffer to the hash to be calculated. * * \param buf The buffer which should be included into calculation. * \param size The size of the buffer | > > > > > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | uint32_t buf[4]; uint32_t bits[2]; uint8_t in[64]; BOOL calculated; } /** * \return A new autoreleased MD5 Hash */ + md5Hash; - init; /** * Adds a buffer to the hash to be calculated. * * \param buf The buffer which should be included into calculation. * \param size The size of the buffer |
︙ | ︙ | |||
53 54 55 56 57 58 59 60 61 62 63 64 65 66 | uint64_t count; uint8_t buffer[64]; uint8_t digest[SHA1_DIGEST_SIZE]; BOOL calculated; } - init; /** * Adds a buffer to the hash to be calculated. * * \param buf The buffer which should be included into calculation. * \param size The size of the buffer | > > > > > | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | uint64_t count; uint8_t buffer[64]; uint8_t digest[SHA1_DIGEST_SIZE]; BOOL calculated; } /** * \return A new autoreleased SHA1 Hash */ + sha1Hash; - init; /** * Adds a buffer to the hash to be calculated. * * \param buf The buffer which should be included into calculation. * \param size The size of the buffer |
︙ | ︙ |
Modified src/OFHashes.m from [7cf61e44ad] to [8790812f47].
︙ | ︙ | |||
111 112 113 114 115 116 117 118 119 120 121 122 123 124 | buf[0] += a; buf[1] += b; buf[2] += c; buf[3] += d; } @implementation OFMD5Hash - init { if ((self = [super init])) { buf[0] = 0x67452301; buf[1] = 0xEFCDAB89; buf[2] = 0x98BADCFE; buf[3] = 0x10325476; | > > > > > | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | buf[0] += a; buf[1] += b; buf[2] += c; buf[3] += d; } @implementation OFMD5Hash + md5Hash { return [[[self alloc] init] autorelease]; } - init { if ((self = [super init])) { buf[0] = 0x67452301; buf[1] = 0xEFCDAB89; buf[2] = 0x98BADCFE; buf[3] = 0x10325476; |
︙ | ︙ | |||
349 350 351 352 353 354 355 356 357 358 359 360 361 362 | } else i = 0; memcpy(&buffer[j], &buf[i], size - i); } @implementation OFSHA1Hash - init { if ((self = [super init])) { count = 0; state[0] = 0x67452301; state[1] = 0xEFCDAB89; state[2] = 0x98BADCFE; | > > > > > | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | } else i = 0; memcpy(&buffer[j], &buf[i], size - i); } @implementation OFSHA1Hash + sha1Hash { return [[[self alloc] init] autorelease]; } - init { if ((self = [super init])) { count = 0; state[0] = 0x67452301; state[1] = 0xEFCDAB89; state[2] = 0x98BADCFE; |
︙ | ︙ |
Modified src/OFList.h from [439fd52763] to [d92e163846].
︙ | ︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 36 | */ @interface OFList: OFObject { of_list_object_t *first; of_list_object_t *last; BOOL retain_and_release; } /** * Initializes an already allocated OFList. * * \param enabled Whether release / retain should be called when an object is * added / removed. Default: YES * \return An initialized OFList | > > > > | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | */ @interface OFList: OFObject { of_list_object_t *first; of_list_object_t *last; BOOL retain_and_release; } /** * \return A new autoreleased OFList */ + list; /** * Initializes an already allocated OFList. * * \param enabled Whether release / retain should be called when an object is * added / removed. Default: YES * \return An initialized OFList |
︙ | ︙ |
Modified src/OFList.m from [f248439ac0] to [d340619ba8].
︙ | ︙ | |||
10 11 12 13 14 15 16 17 18 19 20 21 22 23 | */ #import "config.h" #import "OFList.h" @implementation OFList - init { if ((self = [super init])) { first = NULL; last = NULL; retain_and_release = YES; } | > > > > > | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | */ #import "config.h" #import "OFList.h" @implementation OFList + list { return [[[self alloc] init] autorelease]; } - init { if ((self = [super init])) { first = NULL; last = NULL; retain_and_release = YES; } |
︙ | ︙ |
Modified src/OFNumber.h from [9ee2537120] to [3bc9a9c5bd].
︙ | ︙ | |||
69 70 71 72 73 74 75 | float float_; double double_; long double longdouble; } value; enum of_number_type type; } | | | | | | | | | | | | | | | | | | | | | | | | | 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 | float float_; double double_; long double longdouble; } value; enum of_number_type type; } + numberWithChar: (char)char_; + numberWithShort: (short)short_; + numberWithInt: (int)int_; + numberWithLong: (long)long_; + numberWithUChar: (unsigned char)uchar; + numberWithUShort: (unsigned short)ushort; + numberWithUInt: (unsigned int)uint; + numberWithULong: (unsigned long)ulong; + numberWithInt8: (int8_t)int8; + numberWithInt16: (int16_t)int16; + numberWithInt32: (int32_t)int32; + numberWithInt64: (int64_t)int64; + numberWithUInt8: (uint8_t)uint8; + numberWithUInt16: (uint16_t)uint16; + numberWithUInt32: (uint32_t)uint32; + numberWithUInt64: (uint64_t)uint64; + numberWithSize: (size_t)size; + numberWithSSize: (ssize_t)ssize; + numberWithPtrDiff: (ptrdiff_t)ptrdiff; + numberWithIntPtr: (intptr_t)intptr; + numberWithFloat: (float)float_; + numberWithDouble: (double)double_; + numberWithLongDouble: (long double)longdouble; - initWithChar: (char)char_; - initWithShort: (short)short_; - initWithInt: (int)int_; - initWithLong: (long)long_; - initWithUChar: (unsigned char)uchar; - initWithUShort: (unsigned short)ushort; |
︙ | ︙ |
Modified src/OFNumber.m from [76fb7ad662] to [714973113c].
︙ | ︙ | |||
64 65 66 67 68 69 70 | @throw [OFInvalidFormatException newWithClass: [self class]]; \ \ /* Make gcc happy */ \ return 0; \ } @implementation OFNumber | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 | @throw [OFInvalidFormatException newWithClass: [self class]]; \ \ /* Make gcc happy */ \ return 0; \ } @implementation OFNumber + numberWithChar: (char)char_ { return [[[self alloc] initWithChar: char_] autorelease]; } + numberWithShort: (short)short_ { return [[[self alloc] initWithShort: short_] autorelease]; } + numberWithInt: (int)int_ { return [[[self alloc] initWithInt: int_] autorelease]; } + numberWithLong: (long)long_ { return [[[self alloc] initWithLong: long_] autorelease]; } + numberWithUChar: (unsigned char)uchar { return [[[self alloc] initWithUChar: uchar] autorelease]; } + numberWithUShort: (unsigned short)ushort { return [[[self alloc] initWithUShort: ushort] autorelease]; } + numberWithUInt: (unsigned int)uint { return [[[self alloc] initWithUInt: uint] autorelease]; } + numberWithULong: (unsigned long)ulong { return [[[self alloc] initWithULong: ulong] autorelease]; } + numberWithInt8: (int8_t)int8 { return [[[self alloc] initWithInt8: int8] autorelease]; } + numberWithInt16: (int16_t)int16 { return [[[self alloc] initWithInt16: int16] autorelease]; } + numberWithInt32: (int32_t)int32 { return [[[self alloc] initWithInt32: int32] autorelease]; } + numberWithInt64: (int64_t)int64 { return [[[self alloc] initWithInt64: int64] autorelease]; } + numberWithUInt8: (uint8_t)uint8 { return [[[self alloc] initWithUInt8: uint8] autorelease]; } + numberWithUInt16: (uint16_t)uint16 { return [[[self alloc] initWithUInt16: uint16] autorelease]; } + numberWithUInt32: (uint32_t)uint32 { return [[[self alloc] initWithUInt32: uint32] autorelease]; } + numberWithUInt64: (uint64_t)uint64 { return [[[self alloc] initWithUInt64: uint64] autorelease]; } + numberWithSize: (size_t)size { return [[[self alloc] initWithSize: size] autorelease]; } + numberWithSSize: (ssize_t)ssize { return [[[self alloc] initWithSSize: ssize] autorelease]; } + numberWithPtrDiff: (ptrdiff_t)ptrdiff { return [[[self alloc] initWithPtrDiff: ptrdiff] autorelease]; } + numberWithIntPtr: (intptr_t)intptr { return [[[self alloc] initWithIntPtr: intptr] autorelease]; } + numberWithFloat: (float)float_ { return [[[self alloc] initWithFloat: float_] autorelease]; } + numberWithDouble: (double)double_ { return [[[self alloc] initWithDouble: double_] autorelease]; } + numberWithLongDouble: (long double)longdouble { return [[[self alloc] initWithLongDouble: longdouble] autorelease]; } - initWithChar: (char)char_ { if ((self = [super init])) { value.char_ = char_; type = OF_NUMBER_CHAR; |
︙ | ︙ |
Modified src/OFStream.h from [63e211130f] to [ae18f564f1].
︙ | ︙ | |||
46 47 48 49 50 51 52 53 | /** * Writes a C string into the stream, without the trailing zero. * * \param str The C string from which the data is written to the stream * \return The number of bytes written */ - (size_t)writeCString: (const char*)str; @end | > > > > > | 46 47 48 49 50 51 52 53 54 55 56 57 58 | /** * Writes a C string into the stream, without the trailing zero. * * \param str The C string from which the data is written to the stream * \return The number of bytes written */ - (size_t)writeCString: (const char*)str; /** * Closes the stream. */ - close; @end |
Modified src/OFString.h from [24a3ce2979] to [3f383f6fa1].
︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 | @interface OFString: OFObject { char *string; size_t length; BOOL is_utf8; } /** * Creates a new OFString from a C string. * * \param str A C string to initialize the OFString with | > > > > > | | | | | | | | | | | | | < | 20 21 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 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 | @interface OFString: OFObject { char *string; size_t length; BOOL is_utf8; } /** * \return A new autoreleased OFString */ + string; /** * Creates a new OFString from a C string. * * \param str A C string to initialize the OFString with * \return A new autoreleased OFString */ + stringWithCString: (const char*)str; /** * Creates a new OFString from a format C string. * See printf for the format syntax. * * \param fmt A C string used as format to initialize the OFString * \return A new autoreleased OFString */ + stringWithFormat: (const char*)fmt, ...; /** * Creates a new OFString from a format C string. * See printf for the format syntax. * * \param fmt A C string used as format to initialize the OFString * \param args The arguments used in the format string * \return A new autoreleased OFString */ + stringWithFormat: (const char*)fmt andArguments: (va_list)args; /** * Initializes an already allocated OFString. * * \return An initialized OFString */ - init; /** * Initializes an already allocated OFString from a C string. * * \param str A C string to initialize the OFString with * \return An initialized OFString */ - initWithCString: (const char*)str; /** * Initializes an already allocated OFString from a format C string. * See printf for the format syntax. * * \param fmt A C string used as format to initialize the OFString * \return An initialized OFString */ - initWithFormat: (const char*)fmt, ...; /** * Initializes an already allocated OFString from a format C string. * See printf for the format syntax. * * \param fmt A C string used as format to initialize the OFString * \param args The arguments used in the format string * \return An initialized OFString */ - initWithFormat: (const char*)fmt andArguments: (va_list)args; /** * \return The OFString as a wide C string */ - (const char*)cString; /** * \return The length of the OFString */ - (size_t)length; /** * Clones the OFString, creating a new one. * * \return A new autoreleased copy of the OFString */ - (OFString*)clone; /** * Sets the OFString to the specified OFString. * * \param str An OFString to set the OFString to. */ - setTo: (OFString*)str; /** * Compares the OFString to another OFString. * * \param str An OFString to compare with |
︙ | ︙ |
Modified src/OFString.m from [7c7b5b7fed] to [f753114c1f].
︙ | ︙ | |||
99 100 101 102 103 104 105 | madvise((void*)str, len, MADV_NORMAL); return (utf8 ? 1 : 0); } @implementation OFString | > > > > > | | | | | | | | | | | 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 | madvise((void*)str, len, MADV_NORMAL); return (utf8 ? 1 : 0); } @implementation OFString + string { return [[[self alloc] init] autorelease]; } + stringWithCString: (const char*)str { return [[[self alloc] initWithCString: str] autorelease]; } + stringWithFormat: (const char*)fmt, ... { id ret; va_list args; va_start(args, fmt); ret = [[[self alloc] initWithFormat: fmt andArguments: args] autorelease]; va_end(args); return ret; } + stringWithFormat: (const char*)fmt andArguments: (va_list)args { return [[[self alloc] initWithFormat: fmt andArguments: args] autorelease]; } - init { if ((self = [super init])) { length = 0; string = NULL; is_utf8 = NO; } return self; } - initWithCString: (const char*)str { Class c; if ((self = [super init])) { if (str != NULL) { length = strlen(str); |
︙ | ︙ | |||
162 163 164 165 166 167 168 | memcpy(string, str, length + 1); } } return self; } | | | | | | | 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 | memcpy(string, str, length + 1); } } return self; } - initWithFormat: (const char*)fmt, ... { id ret; va_list args; va_start(args, fmt); ret = [self initWithFormat: fmt andArguments: args]; va_end(args); return ret; } - initWithFormat: (const char*)fmt andArguments: (va_list)args { int t; Class c; if ((self = [super init])) { if (fmt == NULL) { c = [self class]; |
︙ | ︙ | |||
230 231 232 233 234 235 236 | - (size_t)length { return length; } - (OFString*)clone { | | > | > > > > > > > > > > > > > > > > > > > > > | < < < | 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 | - (size_t)length { return length; } - (OFString*)clone { return [OFString stringWithCString: string]; } - setTo: (OFString*)str { size_t len; if (string != NULL) free(string); len = [str length]; switch (check_utf8([str cString], len)) { case 1: is_utf8 = YES; break; case -1: string = NULL; length = 0; is_utf8 = NO; @throw [OFInvalidEncodingException newWithClass: [self class]]; } length = len; string = [self getMemWithSize: length + 1]; memcpy(string, [str cString], length + 1); return self; } - (int)compareTo: (OFString*)str { return strcmp(string, [str cString]); } - append: (OFString*)str { return [self appendCString: [str cString]]; } - appendCString: (const char*)str { char *newstr; size_t newlen, strlength; strlength = strlen(str); switch (check_utf8(str, strlength)) { case 1: is_utf8 = YES; break; case -1: |
︙ | ︙ |
Modified src/OFTCPSocket.h from [f01ceb564c] to [968f2d5f3e].
︙ | ︙ | |||
44 45 46 47 48 49 50 51 52 53 54 55 56 57 | #else SOCKET sock; #endif struct sockaddr *saddr; socklen_t saddr_len; } /** * Initializes an already allocated OFTCPSocket. * * \return An initialized OFTCPSocket */ - init; | > > > > > | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #else SOCKET sock; #endif struct sockaddr *saddr; socklen_t saddr_len; } /** * \return A new autoreleased OFTCPSocket */ + tcpSocket; /** * Initializes an already allocated OFTCPSocket. * * \return An initialized OFTCPSocket */ - init; |
︙ | ︙ |
Modified src/OFTCPSocket.m from [7d0fea78bc] to [c9f6264550].
︙ | ︙ | |||
21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #import "OFExceptions.h" #ifndef INVALID_SOCKET #define INVALID_SOCKET -1 #endif @implementation OFTCPSocket #ifdef _WIN32 + (void)initialize { WSADATA wsa; if (WSAStartup(MAKEWORD(2, 0), &wsa)) @throw [OFInitializationFailedException newWithClass: self]; | > > > > > | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #import "OFExceptions.h" #ifndef INVALID_SOCKET #define INVALID_SOCKET -1 #endif @implementation OFTCPSocket + tcpSocket { return [[[self alloc] init] autorelease]; } #ifdef _WIN32 + (void)initialize { WSADATA wsa; if (WSAStartup(MAKEWORD(2, 0), &wsa)) @throw [OFInitializationFailedException newWithClass: self]; |
︙ | ︙ |
Modified tests/OFArray/OFArray.m from [211a3acfce] to [0b1404de72].
︙ | ︙ | |||
31 32 33 34 35 36 37 | puts("Resuming..."); \ } const char *str = "Hallo!"; #define TEST(type) \ puts("Trying to add too much to an array..."); \ | | | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | puts("Resuming..."); \ } const char *str = "Hallo!"; #define TEST(type) \ puts("Trying to add too much to an array..."); \ a = [[type alloc] initWithItemSize: 4096]; \ CATCH_EXCEPTION([a addNItems: SIZE_MAX \ fromCArray: NULL], \ OFOutOfRangeException) \ \ puts("Trying to add something after that error..."); \ p = [a getMemWithSize: 4096]; \ memset(p, 255, 4096); \ |
︙ | ︙ | |||
89 90 91 92 93 94 95 | puts("Trying to remove more data than we added..."); \ CATCH_EXCEPTION([a removeNItems: [a items] + 1], \ OFOutOfRangeException); \ \ puts("Trying to access an index that does not exist..."); \ CATCH_EXCEPTION([a item: [a items]], OFOutOfRangeException); \ \ | | | | | 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 | puts("Trying to remove more data than we added..."); \ CATCH_EXCEPTION([a removeNItems: [a items] + 1], \ OFOutOfRangeException); \ \ puts("Trying to access an index that does not exist..."); \ CATCH_EXCEPTION([a item: [a items]], OFOutOfRangeException); \ \ [a release]; \ \ puts("Creating new array and using it to build a string..."); \ a = [[type alloc] initWithItemSize: 1]; \ \ for (i = 0; i < strlen(str); i++) \ [a add: (void*)&str[i]]; \ [a add: ""]; \ \ if (!strcmp([a data], str)) \ puts("Built string matches!"); \ else { \ puts("Built string does not match!"); \ abort(); \ } \ \ [a release]; int main() { id a; void *p, *q; size_t i; |
︙ | ︙ |
Modified tests/OFHashes/OFHashes.m from [4cc440481a] to [c778845c1b].
︙ | ︙ | |||
25 26 27 28 29 30 31 | int main() { uint8_t buf[64]; size_t len; | | | | | | < < | 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 58 59 60 61 62 63 | int main() { uint8_t buf[64]; size_t len; OFMD5Hash *md5 = [OFMD5Hash md5Hash]; OFSHA1Hash *sha1 = [OFSHA1Hash sha1Hash]; OFFile *f = [OFFile fileWithPath: "testfile" andMode: "rb"]; while (![f atEndOfFile]) { len = [f readNBytes: 64 intoBuffer: buf]; [md5 updateWithBuffer: buf ofSize: len]; [sha1 updateWithBuffer: buf ofSize: len]; } [f close]; if (!memcmp([md5 digest], testfile_md5, MD5_DIGEST_SIZE)) { fputs("\r\033[1;33mTests successful: 1/2\033[0m", stdout); fflush(stdout); } else { puts("\r\033[K\033[1;31mTest 1/2 failed!\033[0m"); return 1; } if (!memcmp([sha1 digest], testfile_sha1, SHA1_DIGEST_SIZE)) puts("\r\033[1;32mTests successful: 2/2\033[0m"); else { puts("\r\033[K\033[1;31mTest 2/2 failed!\033[0m"); return 1; } return 0; } |
Modified tests/OFList/OFList.m from [147b8c86d0] to [61b6eedfea].
︙ | ︙ | |||
55 56 57 58 59 60 61 | int main() { size_t i, j; OFList *list; of_list_object_t *iter; | | | | | | | | 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 | int main() { size_t i, j; OFList *list; of_list_object_t *iter; list = [OFList list]; [list append: [OFString stringWithCString: strings[0]]]; [list append: [OFString stringWithCString: strings[1]]]; [list append: [OFString stringWithCString: strings[2]]]; for (iter = [list first], i = 0; iter != NULL; iter = iter->next, i++) if (!strcmp([iter->object cString], strings[i])) SUCCESS else FAIL CHECK(!strcmp([[list first]->object cString], strings[0])) CHECK(!strcmp([[list last]->object cString], strings[2])) [list remove: [list last]]; CHECK(!strcmp([[list last]->object cString], strings[1])) [list remove: [list first]]; CHECK(!strcmp([[list first]->object cString], [[list last]->object cString])) [list insert: [OFString stringWithCString: strings[0]] before: [list last]]; [list insert: [OFString stringWithCString: strings[2]] after: [list first]->next]; for (iter = [list first], j = 0; iter != NULL; iter = iter->next, j++) CHECK(!strcmp([iter->object cString], strings[j])) puts(""); return 0; } |
Modified tests/OFString/OFString.m from [a85f1b3a10] to [ffc025b2b3].
︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #import "config.h" #import <string.h> #import "OFString.h" #import "OFExceptions.h" #import <stdio.h> #ifndef _WIN32 #define ZD "%zd" #else #define ZD "%u" | > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | #import "config.h" #import <string.h> #import "OFString.h" #import "OFExceptions.h" #import "OFAutoreleasePool.h" #import <stdio.h> #ifndef _WIN32 #define ZD "%zd" #else #define ZD "%u" |
︙ | ︙ | |||
50 51 52 53 54 55 56 | i++; int main() { size_t i = 0; | > | | | | < < < | | | | | 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 | i++; int main() { size_t i = 0; OFAutoreleasePool *pool = [OFAutoreleasePool new]; OFString *s1 = [OFString stringWithCString: "test"]; OFString *s2 = [OFString stringWithCString: ""]; OFString *s3; OFString *s4 = [OFString string]; s3 = [s1 clone]; CHECK(![s1 compareTo: s3]) [s2 appendCString: "123"]; [s4 setTo: s2]; CHECK(![s2 compareTo: s4]) CHECK(!strcmp([[s1 append: s2] cString], "test123")) CHECK(strlen([s1 cString]) == [s1 length] && [s1 length] == 7) CHECK(!strcmp([[s1 reverse] cString], "321tset")) CHECK(!strcmp([[s1 upper] cString], "321TSET")) CHECK(!strcmp([[s1 lower] cString], "321tset")) /* Also clears all the memory of the returned C strings */ [pool release]; /* UTF-8 tests */ CHECK_EXCEPT(s1 = [OFString stringWithCString: "\xE0\x80"], OFInvalidEncodingException) CHECK_EXCEPT(s1 = [OFString stringWithCString: "\xF0\x80\x80\xC0"], OFInvalidEncodingException) s1 = [OFString stringWithCString: "äöü€𝄞"]; CHECK(!strcmp([[s1 reverse] cString], "𝄞€üöä")) [s1 free]; /* Format tests */ s1 = [OFString stringWithFormat: "%s: %d", "test", 123]; CHECK(!strcmp([s1 cString], "test: 123")) [s1 appendWithFormatCString: "%02X", 15]; CHECK(!strcmp([s1 cString], "test: 1230F")) puts(""); return 0; } |
Modified tests/OFTCPSocket/OFTCPSocket.m from [0858553e55] to [f9f0278503].
︙ | ︙ | |||
34 35 36 37 38 39 40 | main() { uint16_t port; srand(time(NULL)); @try { | | | | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | main() { uint16_t port; srand(time(NULL)); @try { OFTCPSocket *server = [OFTCPSocket tcpSocket]; OFTCPSocket *client = [OFTCPSocket tcpSocket]; OFTCPSocket *accepted; char buf[7]; puts("== IPv4 =="); port = get_port(); [server bindOn: "localhost" |
︙ | ︙ | |||
67 68 69 70 71 72 73 | puts("Received INCORRECT string!"); return 1; } #ifdef HAVE_IPV6 memset(buf, 0, 7); | | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | puts("Received INCORRECT string!"); return 1; } #ifdef HAVE_IPV6 memset(buf, 0, 7); [accepted release]; [client close]; [server close]; puts("== IPv6 =="); port = get_port(); [server bindOn: "::1" |
︙ | ︙ | |||
97 98 99 100 101 102 103 | puts("Received correct string!"); else { puts("Received INCORRECT string!"); return 1; } #endif | | | | | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | puts("Received correct string!"); else { puts("Received INCORRECT string!"); return 1; } #endif [accepted release]; [client release]; [server release]; } @catch(OFException *e) { printf("EXCEPTION: %s\n", [e cString]); return 1; } return 0; } |