Changeset 221583 in webkit for trunk/Source/JavaScriptCore/API
- Timestamp:
- Sep 4, 2017, 2:24:21 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSWrapperMap.mm
r218379 r221583 63 63 @end 64 64 65 static const constexpr unsigned InitialBufferSize { 256 }; 66 65 67 // Default conversion of selectors to property names. 66 68 // All semicolons are removed, lowercase letters following a semicolon are capitalized. … … 76 78 // The new string needs to be long enough to hold 'header', plus the remainder of the string, excluding 77 79 // at least one ':', but including a '\0'. (This is conservative if there are more than one ':'). 78 char* buffer = static_cast<char*>(malloc(header + strlen(firstColon + 1) + 1));80 Vector<char, InitialBufferSize> buffer(header + strlen(firstColon + 1) + 1); 79 81 // Copy 'header' characters, set output to point to the end of this & input to point past the first ':'. 80 memcpy(buffer , start, header);81 char* output = buffer + header;82 memcpy(buffer.data(), start, header); 83 char* output = buffer.data() + header; 82 84 const char* input = start + header + 1; 83 85 … … 102 104 } 103 105 done: 104 NSString *result = [NSString stringWithUTF8String:buffer]; 105 free(buffer); 106 return result; 106 return [NSString stringWithUTF8String:buffer.data()]; 107 107 } 108 108
Note:
See TracChangeset
for help on using the changeset viewer.