Overview
Comment: | OFString: Improve freeWhenDone in case of error |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | 0.90 |
Files: | files | file ages | folders |
SHA3-256: |
ca0621da090ab343991a51812e401c68 |
User & Date: | js on 2017-11-04 21:12:49 |
Other Links: | branch diff | manifest | tags |
Context
2018-04-15
| ||
14:50 | OFLocalization: Fix setting the territory check-in: 5fcee684cb user: js tags: 0.90 | |
2017-11-04
| ||
21:12 | OFString: Improve freeWhenDone in case of error check-in: ca0621da09 user: js tags: 0.90 | |
20:58 | OFString_UTF8: Fix BOM handling in no copy init check-in: 1aca64c18e user: js tags: 0.90 | |
Changes
Modified src/OFString.h from [bb11f44cdb] to [7c41844eaa].
︙ | ︙ | |||
137 138 139 140 141 142 143 | * @return A new autoreleased OFString */ + (instancetype)stringWithUTF8String: (const char *)UTF8String length: (size_t)UTF8StringLength; /*! * @brief Creates a new OFString from a UTF-8 encoded C string without copying | | > > > > > | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | * @return A new autoreleased OFString */ + (instancetype)stringWithUTF8String: (const char *)UTF8String length: (size_t)UTF8StringLength; /*! * @brief Creates a new OFString from a UTF-8 encoded C string without copying * the string, if possible. * * If initialization fails for whatever reason, the passed C string is free'd * if `freeWhenDone` is true. * * @note OFMutableString always creates a copy! * * @param UTF8String A UTF-8 encoded C string to initialize the OFString with * @param freeWhenDone Whether to free the C string when the OFString gets * deallocated * @return A new autoreleased OFString */ + (instancetype)stringWithUTF8StringNoCopy: (char *)UTF8String |
︙ | ︙ | |||
378 379 380 381 382 383 384 | * @return An initialized OFString */ - initWithUTF8String: (const char *)UTF8String length: (size_t)UTF8StringLength; /*! * @brief Initializes an already allocated OFString from an UTF-8 encoded C | | > > > | | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | * @return An initialized OFString */ - initWithUTF8String: (const char *)UTF8String length: (size_t)UTF8StringLength; /*! * @brief Initializes an already allocated OFString from an UTF-8 encoded C * string without copying the string, if possible. * * If initialization fails for whatever reason, the passed C string is free'd * if `freeWhenDone` is true. * * @note OFMutableString always creates a copy! * * @param UTF8String A UTF-8 encoded C string to initialize the OFString with * @param freeWhenDone Whether to free the C string when it is not needed * anymore * @return An initialized OFString */ - initWithUTF8StringNoCopy: (char *)UTF8String |
︙ | ︙ |
Modified src/OFString.m from [29ce2b94a9] to [e6724ae75a].
︙ | ︙ | |||
846 847 848 849 850 851 852 | encoding: OF_STRING_ENCODING_UTF_8 length: UTF8StringLength]; } - initWithUTF8StringNoCopy: (char *)UTF8String freeWhenDone: (bool)freeWhenDone { | > | > > > > | 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 | encoding: OF_STRING_ENCODING_UTF_8 length: UTF8StringLength]; } - initWithUTF8StringNoCopy: (char *)UTF8String freeWhenDone: (bool)freeWhenDone { @try { return [self initWithUTF8String: UTF8String]; } @finally { if (freeWhenDone) free(UTF8String); } } - initWithCString: (const char *)cString encoding: (of_string_encoding_t)encoding { return [self initWithCString: cString encoding: encoding |
︙ | ︙ |
Modified src/OFString_UTF8.m from [77d4090528] to [0ee13f2fd8].
︙ | ︙ | |||
389 390 391 392 393 394 395 | return self; } - initWithUTF8StringNoCopy: (char *)UTF8String freeWhenDone: (bool)freeWhenDone { | > | > > > > > | 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | return self; } - initWithUTF8StringNoCopy: (char *)UTF8String freeWhenDone: (bool)freeWhenDone { @try { self = [super init]; } @catch (id e) { if (freeWhenDone) free(UTF8String); @throw e; } @try { size_t UTF8StringLength = strlen(UTF8String); _s = &_storage; if (freeWhenDone) |
︙ | ︙ |