Differences From Artifact [9a6d67963b]:
- File src/OFConstantString.m — part of check-in [e8d6ca16e7] at 2013-03-08 23:00:50 on branch trunk — Take advantage of realloc(NULL, n) being defined. (user: js, size: 11870) [annotate] [blame] [check-ins using]
To Artifact [8447dff468]:
- File
src/OFConstantString.m
— part of check-in
[abb7536cdd]
at
2013-05-01 20:35:40
on branch trunk
— Make -[finishInitialization] thread-safe.
This way, it's possible to use the same constant string from multiple
threads without having to make sure it's initialized first. (user: js, size: 11993) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
142 143 144 145 146 147 148 | free(class); objc_registerClassPair((Class)&_OFConstantStringClassReference); #endif } - (void)finishInitialization { | > | > > > | | | | | | | > | | | | | | | | | | | > | 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 | free(class); objc_registerClassPair((Class)&_OFConstantStringClassReference); #endif } - (void)finishInitialization { @synchronized (self) { struct of_string_utf8_ivars *ivars; if (object_getClass(self) == [OFString_const class]) return; if ((ivars = calloc(1, sizeof(*ivars))) == NULL) @throw [OFOutOfMemoryException exceptionWithClass: [self class] requestedSize: sizeof(*ivars)]; ivars->cString = _cString; ivars->cStringLength = _cStringLength; switch (of_string_utf8_check(ivars->cString, ivars->cStringLength, &ivars->length)) { case 1: ivars->isUTF8 = true; break; case -1: free(ivars); @throw [OFInvalidEncodingException exceptionWithClass: [self class]]; } _cString = (char*)ivars; object_setClass(self, [OFString_const class]); } } + alloc { [self doesNotRecognizeSelector: _cmd]; abort(); } |
︙ | ︙ |