Differences From Artifact [91d4470735]:
- File
src/OFString.m
— part of check-in
[aeb403a1ed]
at
2020-10-10 14:27:37
on branch trunk
— OFObject: Change type of -[hash] to unsigned long
The internal hash is still 32 bit in most places, but this way, it is at
least not baked into the API and ABI and can be upgraded later, should
that ever be necessary. (user: js, size: 65567) [annotate] [blame] [check-ins using]
To Artifact [25e18e82dd]:
- File src/OFString.m — part of check-in [d0ae3bfd6c] at 2020-10-25 23:33:09 on branch trunk — Add of_{malloc,calloc,realloc,free} (user: js, size: 65252) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
838 839 840 841 842 843 844 | { id ret; @try { ret = [self initWithUTF8String: UTF8String]; } @finally { if (freeWhenDone) | | | | 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 866 867 868 869 | { id ret; @try { ret = [self initWithUTF8String: UTF8String]; } @finally { if (freeWhenDone) of_free(UTF8String); } return ret; } - (instancetype)initWithUTF8StringNoCopy: (char *)UTF8String length: (size_t)UTF8StringLength freeWhenDone: (bool)freeWhenDone { id ret; @try { ret = [self initWithUTF8String: UTF8String length: UTF8StringLength]; } @finally { if (freeWhenDone) of_free(UTF8String); } return ret; } - (instancetype)initWithCString: (const char *)cString encoding: (of_string_encoding_t)encoding |
︙ | ︙ | |||
1025 1026 1027 1028 1029 1030 1031 | /* * We need one extra byte for the terminating zero if we want * to use -[initWithUTF8StringNoCopy:length:freeWhenDone:]. */ if (SIZE_MAX - (size_t)fileSize < 1) @throw [OFOutOfRangeException exception]; | | < < < | | 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 | /* * We need one extra byte for the terminating zero if we want * to use -[initWithUTF8StringNoCopy:length:freeWhenDone:]. */ if (SIZE_MAX - (size_t)fileSize < 1) @throw [OFOutOfRangeException exception]; tmp = of_malloc(1, (size_t)fileSize + 1); @try { file = [[OFFile alloc] initWithPath: path mode: @"r"]; [file readIntoBuffer: tmp exactLength: (size_t)fileSize]; } @catch (id e) { of_free(tmp); @throw e; } @finally { [file release]; } tmp[(size_t)fileSize] = '\0'; } @catch (id e) { |
︙ | ︙ | |||
1058 1059 1060 1061 1062 1063 1064 | freeWhenDone: true]; else { @try { self = [self initWithCString: tmp encoding: encoding length: (size_t)fileSize]; } @finally { | | | 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 | freeWhenDone: true]; else { @try { self = [self initWithCString: tmp encoding: encoding length: (size_t)fileSize]; } @finally { of_free(tmp); } } return self; } #endif |
︙ | ︙ | |||
1856 1857 1858 1859 1860 1861 1862 | if (range.length > SIZE_MAX / sizeof(of_unichar_t)) @throw [OFOutOfRangeException exception]; pool = objc_autoreleasePoolPush(); searchCharacters = string.characters; | < < | < | 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 | if (range.length > SIZE_MAX / sizeof(of_unichar_t)) @throw [OFOutOfRangeException exception]; pool = objc_autoreleasePoolPush(); searchCharacters = string.characters; characters = of_malloc(range.length, sizeof(of_unichar_t)); @try { [self getCharacters: characters inRange: range]; if (options & OF_STRING_SEARCH_BACKWARDS) { for (size_t i = range.length - searchLength;; i--) { if (memcmp(characters + i, searchCharacters, |
︙ | ︙ | |||
1889 1890 1891 1892 1893 1894 1895 | objc_autoreleasePoolPop(pool); return of_range(range.location + i, searchLength); } } } } @finally { | | | 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 | objc_autoreleasePoolPop(pool); return of_range(range.location + i, searchLength); } } } } @finally { of_free(characters); } objc_autoreleasePoolPop(pool); return of_range(OF_NOT_FOUND, 0); } |
︙ | ︙ | |||
1927 1928 1929 1930 1931 1932 1933 | if (range.length == 0) return OF_NOT_FOUND; if (range.length > SIZE_MAX / sizeof(of_unichar_t)) @throw [OFOutOfRangeException exception]; | < < | < | 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 | if (range.length == 0) return OF_NOT_FOUND; if (range.length > SIZE_MAX / sizeof(of_unichar_t)) @throw [OFOutOfRangeException exception]; characters = of_malloc(range.length, sizeof(of_unichar_t)); @try { [self getCharacters: characters inRange: range]; if (options & OF_STRING_SEARCH_BACKWARDS) { for (size_t i = range.length - 1;; i--) { if (characterIsMember(characterSet, |
︙ | ︙ | |||
1954 1955 1956 1957 1958 1959 1960 | for (size_t i = 0; i < range.length; i++) if (characterIsMember(characterSet, @selector(characterIsMember:), characters[i])) return range.location + i; } } @finally { | | | 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 | for (size_t i = 0; i < range.length; i++) if (characterIsMember(characterSet, @selector(characterIsMember:), characters[i])) return range.location + i; } } @finally { of_free(characters); } return OF_NOT_FOUND; } - (bool)containsString: (OFString *)string { |
︙ | ︙ |