Differences From Artifact [ab9d9164f8]:
- File
src/OFString.m
— part of check-in
[a2b4238850]
at
2020-11-06 02:24:14
on branch trunk
— Future-proof some code using freeWhenDone
While -[OFData initWithDataNoCopy:count:itemSize:freeWhenDone:] can
currently never throw, it might in the future, and when it does so in
the future, these would be memory leaks then. (user: js, size: 65979) [annotate] [blame] [check-ins using]
To Artifact [7044157852]:
- File
src/OFString.m
— part of check-in
[0f260e0fd5]
at
2020-11-06 02:37:02
on branch trunk
— OFString: Make freeWhenDone behave like in OFData
In particular, this means that if initialization fails, the buffer is
NOT free'd. While freeing it on error in convenient when not handling
the error, it makes handling the error and retrying impossible (e.g.
retrying with a different encoding). (user: js, size: 65913) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
832 833 834 835 836 837 838 | encoding: OF_STRING_ENCODING_UTF_8 length: UTF8StringLength]; } - (instancetype)initWithUTF8StringNoCopy: (char *)UTF8String freeWhenDone: (bool)freeWhenDone { | | < < < | | < < < < | | | | | < | 832 833 834 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 | encoding: OF_STRING_ENCODING_UTF_8 length: UTF8StringLength]; } - (instancetype)initWithUTF8StringNoCopy: (char *)UTF8String freeWhenDone: (bool)freeWhenDone { id ret = [self initWithUTF8String: UTF8String]; if (freeWhenDone) free(UTF8String); return ret; } - (instancetype)initWithUTF8StringNoCopy: (char *)UTF8String length: (size_t)UTF8StringLength freeWhenDone: (bool)freeWhenDone { id ret = [self initWithUTF8String: UTF8String length: UTF8StringLength]; if (freeWhenDone) free(UTF8String); return ret; } - (instancetype)initWithCString: (const char *)cString encoding: (of_string_encoding_t)encoding { |
︙ | ︙ |