Title: [221583] trunk/Source
Revision
221583
Author
[email protected]
Date
2017-09-04 02:24:21 -0700 (Mon, 04 Sep 2017)

Log Message

Remove "malloc" and "free" use
https://bugs.webkit.org/show_bug.cgi?id=176310

Reviewed by Darin Adler.

Source/_javascript_Core:

Use Vector instead.

* API/JSWrapperMap.mm:
(selectorToPropertyName):

Source/WebCore:

Use MallocPtr<>, fastMalloc/fastFree, or Vector instead of manual call of system malloc/free.
In this patch, we apply the above change if we can easily find the pair of malloc/free.
And we do not touch plugin directory since the external code could call free() onto the
fastMalloc-ed memory.

Also, we still use malloc if the system adopts the allocated memory. Later, the system
will deallocate it by calling the system "free".

* platform/audio/mac/FFTFrameMac.cpp:
(WebCore::FFTFrame::fftSetupForSize):
(WebCore::FFTFrame::cleanup):
* platform/graphics/win/FontCacheWin.cpp:
(WebCore::getLinkedFonts):
* platform/graphics/win/FontCustomPlatformData.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData):
* platform/graphics/win/FontPlatformDataWin.cpp:
(WebCore::FontPlatformData::FontPlatformData):
* platform/mac/WebCoreNSURLExtras.mm:
(WebCore::URLByTruncatingOneCharacterBeforeComponent):
(WebCore::dataForURLComponentType):
(WebCore::URLByRemovingComponentAndSubsequentCharacter):
(WebCore::createStringWithEscapedUnsafeCharacters):
(WebCore::userVisibleString):
* platform/win/ClipboardUtilitiesWin.cpp:
(WebCore::markupToCFHTML):

Source/WTF:

Use Vector instead.

* wtf/Assertions.cpp:

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/JSWrapperMap.mm (221582 => 221583)


--- trunk/Source/_javascript_Core/API/JSWrapperMap.mm	2017-09-04 09:24:06 UTC (rev 221582)
+++ trunk/Source/_javascript_Core/API/JSWrapperMap.mm	2017-09-04 09:24:21 UTC (rev 221583)
@@ -62,6 +62,8 @@
 
 @end
 
+static const constexpr unsigned InitialBufferSize { 256 };
+
 // Default conversion of selectors to property names.
 // All semicolons are removed, lowercase letters following a semicolon are capitalized.
 static NSString *selectorToPropertyName(const char* start)
@@ -75,10 +77,10 @@
     size_t header = firstColon - start;
     // The new string needs to be long enough to hold 'header', plus the remainder of the string, excluding
     // at least one ':', but including a '\0'. (This is conservative if there are more than one ':').
-    char* buffer = static_cast<char*>(malloc(header + strlen(firstColon + 1) + 1));
+    Vector<char, InitialBufferSize> buffer(header + strlen(firstColon + 1) + 1);
     // Copy 'header' characters, set output to point to the end of this & input to point past the first ':'.
-    memcpy(buffer, start, header);
-    char* output = buffer + header;
+    memcpy(buffer.data(), start, header);
+    char* output = buffer.data() + header;
     const char* input = start + header + 1;
 
     // On entry to the loop, we have already skipped over a ':' from the input.
@@ -101,9 +103,7 @@
         // If we get here, we've consumed a ':' - wash, rinse, repeat.
     }
 done:
-    NSString *result = [NSString stringWithUTF8String:buffer];
-    free(buffer);
-    return result;
+    return [NSString stringWithUTF8String:buffer.data()];
 }
 
 static bool constructorHasInstance(JSContextRef ctx, JSObjectRef constructorRef, JSValueRef possibleInstance, JSValueRef*)

Modified: trunk/Source/_javascript_Core/ChangeLog (221582 => 221583)


--- trunk/Source/_javascript_Core/ChangeLog	2017-09-04 09:24:06 UTC (rev 221582)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-09-04 09:24:21 UTC (rev 221583)
@@ -1,3 +1,15 @@
+2017-09-03  Yusuke Suzuki  <[email protected]>
+
+        Remove "malloc" and "free" use
+        https://bugs.webkit.org/show_bug.cgi?id=176310
+
+        Reviewed by Darin Adler.
+
+        Use Vector instead.
+
+        * API/JSWrapperMap.mm:
+        (selectorToPropertyName):
+
 2017-09-03  Darin Adler  <[email protected]>
 
         Try to fix Windows build.

Modified: trunk/Source/WTF/ChangeLog (221582 => 221583)


--- trunk/Source/WTF/ChangeLog	2017-09-04 09:24:06 UTC (rev 221582)
+++ trunk/Source/WTF/ChangeLog	2017-09-04 09:24:21 UTC (rev 221583)
@@ -1,3 +1,14 @@
+2017-09-03  Yusuke Suzuki  <[email protected]>
+
+        Remove "malloc" and "free" use
+        https://bugs.webkit.org/show_bug.cgi?id=176310
+
+        Reviewed by Darin Adler.
+
+        Use Vector instead.
+
+        * wtf/Assertions.cpp:
+
 2017-09-04  Yusuke Suzuki  <[email protected]>
 
         Unreviewed, support libstdc++ use with clang

Modified: trunk/Source/WTF/wtf/Assertions.cpp (221582 => 221583)


--- trunk/Source/WTF/wtf/Assertions.cpp	2017-09-04 09:24:06 UTC (rev 221582)
+++ trunk/Source/WTF/wtf/Assertions.cpp	2017-09-04 09:24:21 UTC (rev 221583)
@@ -42,6 +42,7 @@
 #include <wtf/Locker.h>
 #include <wtf/LoggingAccumulator.h>
 #include <wtf/PrintStream.h>
+#include <wtf/RetainPtr.h>
 #include <wtf/StackTrace.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/StringExtras.h>
@@ -87,31 +88,29 @@
     fputs(buffer, stderr);
 }
 
+static const constexpr unsigned InitialBufferSize { 256 };
+
 WTF_ATTRIBUTE_PRINTF(1, 0)
 static void vprintf_stderr_common(const char* format, va_list args)
 {
 #if USE(CF) && !OS(WINDOWS)
     if (strstr(format, "%@")) {
-        CFStringRef cfFormat = CFStringCreateWithCString(NULL, format, kCFStringEncodingUTF8);
+        auto cfFormat = adoptCF(CFStringCreateWithCString(nullptr, format, kCFStringEncodingUTF8));
 
 #if COMPILER(CLANG)
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wformat-nonliteral"
 #endif
-        CFStringRef str = CFStringCreateWithFormatAndArguments(NULL, NULL, cfFormat, args);
+        auto str = adoptCF(CFStringCreateWithFormatAndArguments(nullptr, nullptr, cfFormat.get(), args));
 #if COMPILER(CLANG)
 #pragma clang diagnostic pop
 #endif
-        CFIndex length = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str), kCFStringEncodingUTF8);
-        char* buffer = (char*)malloc(length + 1);
+        CFIndex length = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str.get()), kCFStringEncodingUTF8);
+        Vector<char, InitialBufferSize> buffer(length + 1);
 
-        CFStringGetCString(str, buffer, length, kCFStringEncodingUTF8);
+        CFStringGetCString(str.get(), buffer.data(), length, kCFStringEncodingUTF8);
 
-        logToStderr(buffer);
-
-        free(buffer);
-        CFRelease(str);
-        CFRelease(cfFormat);
+        logToStderr(buffer.data());
         return;
     }
 
@@ -130,20 +129,13 @@
 #elif HAVE(ISDEBUGGERPRESENT)
     if (IsDebuggerPresent()) {
         size_t size = 1024;
-
+        Vector<char> buffer(size);
         do {
-            char* buffer = (char*)malloc(size);
-
-            if (buffer == NULL)
+            buffer.grow(size);
+            if (vsnprintf(buffer.get(), size, format, args) != -1) {
+                OutputDebugStringA(buffer.get());
                 break;
-
-            if (vsnprintf(buffer, size, format, args) != -1) {
-                OutputDebugStringA(buffer);
-                free(buffer);
-                break;
             }
-
-            free(buffer);
             size *= 2;
         } while (size > 1024);
     }

Modified: trunk/Source/WebCore/ChangeLog (221582 => 221583)


--- trunk/Source/WebCore/ChangeLog	2017-09-04 09:24:06 UTC (rev 221582)
+++ trunk/Source/WebCore/ChangeLog	2017-09-04 09:24:21 UTC (rev 221583)
@@ -1,3 +1,36 @@
+2017-09-03  Yusuke Suzuki  <[email protected]>
+
+        Remove "malloc" and "free" use
+        https://bugs.webkit.org/show_bug.cgi?id=176310
+
+        Reviewed by Darin Adler.
+
+        Use MallocPtr<>, fastMalloc/fastFree, or Vector instead of manual call of system malloc/free.
+        In this patch, we apply the above change if we can easily find the pair of malloc/free.
+        And we do not touch plugin directory since the external code could call free() onto the
+        fastMalloc-ed memory.
+
+        Also, we still use malloc if the system adopts the allocated memory. Later, the system
+        will deallocate it by calling the system "free".
+
+        * platform/audio/mac/FFTFrameMac.cpp:
+        (WebCore::FFTFrame::fftSetupForSize):
+        (WebCore::FFTFrame::cleanup):
+        * platform/graphics/win/FontCacheWin.cpp:
+        (WebCore::getLinkedFonts):
+        * platform/graphics/win/FontCustomPlatformData.cpp:
+        (WebCore::FontCustomPlatformData::fontPlatformData):
+        * platform/graphics/win/FontPlatformDataWin.cpp:
+        (WebCore::FontPlatformData::FontPlatformData):
+        * platform/mac/WebCoreNSURLExtras.mm:
+        (WebCore::URLByTruncatingOneCharacterBeforeComponent):
+        (WebCore::dataForURLComponentType):
+        (WebCore::URLByRemovingComponentAndSubsequentCharacter):
+        (WebCore::createStringWithEscapedUnsafeCharacters):
+        (WebCore::userVisibleString):
+        * platform/win/ClipboardUtilitiesWin.cpp:
+        (WebCore::markupToCFHTML):
+
 2017-09-03  Chris Dumez  <[email protected]>
 
         Use StringView in DOMFileSystem::evaluatePath()

Modified: trunk/Source/WebCore/platform/audio/mac/FFTFrameMac.cpp (221582 => 221583)


--- trunk/Source/WebCore/platform/audio/mac/FFTFrameMac.cpp	2017-09-04 09:24:06 UTC (rev 221582)
+++ trunk/Source/WebCore/platform/audio/mac/FFTFrameMac.cpp	2017-09-04 09:24:21 UTC (rev 221583)
@@ -146,7 +146,7 @@
 FFTSetup FFTFrame::fftSetupForSize(unsigned fftSize)
 {
     if (!fftSetups) {
-        fftSetups = (FFTSetup*)malloc(sizeof(FFTSetup) * kMaxFFTPow2Size);
+        fftSetups = (FFTSetup*)fastMalloc(sizeof(FFTSetup) * kMaxFFTPow2Size);
         memset(fftSetups, 0, sizeof(FFTSetup) * kMaxFFTPow2Size);
     }
 
@@ -172,7 +172,7 @@
             vDSP_destroy_fftsetup(fftSetups[i]);
     }
 
-    free(fftSetups);
+    fastFree(fftSetups);
     fftSetups = 0;
 }
 

Modified: trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp (221582 => 221583)


--- trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp	2017-09-04 09:24:06 UTC (rev 221582)
+++ trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp	2017-09-04 09:24:21 UTC (rev 221583)
@@ -137,12 +137,12 @@
         return result;
     }
 
-    WCHAR* linkedFonts = reinterpret_cast<WCHAR*>(malloc(linkedFontsBufferSize));
-    if (::RegQueryValueEx(fontLinkKey, family.charactersWithNullTermination().data(), 0, nullptr, reinterpret_cast<BYTE*>(linkedFonts), &linkedFontsBufferSize) == ERROR_SUCCESS) {
-        unsigned length = linkedFontsBufferSize / sizeof(*linkedFonts);
-        appendLinkedFonts(linkedFonts, length, result);
+    static const constexpr unsigned InitialBufferSize { 256 / sizeof(WCHAR) };
+    Vector<WCHAR, InitialBufferSize> linkedFonts(roundUpToMultipleOf<sizeof(WCHAR)>(linkedFontsBufferSize) / sizeof(WCHAR));
+    if (::RegQueryValueEx(fontLinkKey, family.charactersWithNullTermination().data(), 0, nullptr, reinterpret_cast<BYTE*>(linkedFonts.data()), &linkedFontsBufferSize) == ERROR_SUCCESS) {
+        unsigned length = linkedFontsBufferSize / sizeof(WCHAR);
+        appendLinkedFonts(linkedFonts.data(), length, result);
     }
-    free(linkedFonts);
     RegCloseKey(fontLinkKey);
     return result;
 }

Modified: trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp (221582 => 221583)


--- trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp	2017-09-04 09:24:06 UTC (rev 221582)
+++ trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp	2017-09-04 09:24:21 UTC (rev 221583)
@@ -54,7 +54,7 @@
 
     ASSERT(m_fontReference);
 
-    LOGFONT& logFont = *static_cast<LOGFONT*>(malloc(sizeof(LOGFONT)));
+    LOGFONT logFont { };
     memcpy(logFont.lfFaceName, m_name.charactersWithNullTermination().data(), sizeof(logFont.lfFaceName[0]) * std::min<size_t>(static_cast<size_t>(LF_FACESIZE), 1 + m_name.length()));
 
     logFont.lfHeight = -size;

Modified: trunk/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp (221582 => 221583)


--- trunk/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp	2017-09-04 09:24:06 UTC (rev 221582)
+++ trunk/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp	2017-09-04 09:24:21 UTC (rev 221583)
@@ -57,14 +57,14 @@
     ASSERT_WITH_MESSAGE(bufferSize, "Bitmap fonts not supported with CoreGraphics.");
 
     if (bufferSize) {
-        OUTLINETEXTMETRICW* metrics = (OUTLINETEXTMETRICW*)malloc(bufferSize);
+        static const constexpr unsigned InitialBufferSize { 256 };
+        Vector<char, 256> buffer(bufferSize);
+        auto* metrics = reinterpret_cast<OUTLINETEXTMETRICW*>(buffer.data());
 
         GetOutlineTextMetricsW(hdc, bufferSize, metrics);
         WCHAR* faceName = (WCHAR*)((uintptr_t)metrics + (uintptr_t)metrics->otmpFaceName);
 
         platformDataInit(m_font->get(), size, hdc, faceName);
-
-        free(metrics);
     }
 
     RestoreDC(hdc, -1);

Modified: trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm (221582 => 221583)


--- trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm	2017-09-04 09:24:06 UTC (rev 221582)
+++ trunk/Source/WebCore/platform/mac/WebCoreNSURLExtras.mm	2017-09-04 09:24:21 UTC (rev 221583)
@@ -750,21 +750,18 @@
     if (fragRg.location == kCFNotFound)
         return URL;
     
-    UInt8 *urlBytes, buffer[2048];
-    CFIndex numBytes = CFURLGetBytes((CFURLRef)URL, buffer, 2048);
+    Vector<UInt8, URL_BYTES_BUFFER_LENGTH> urlBytes(URL_BYTES_BUFFER_LENGTH);
+    CFIndex numBytes = CFURLGetBytes((CFURLRef)URL, urlBytes.data(), urlBytes.size());
     if (numBytes == -1) {
         numBytes = CFURLGetBytes((CFURLRef)URL, NULL, 0);
-        urlBytes = static_cast<UInt8*>(malloc(numBytes));
-        CFURLGetBytes((CFURLRef)URL, urlBytes, numBytes);
-    } else
-        urlBytes = buffer;
-        
-    NSURL *result = (NSURL *)CFURLCreateWithBytes(NULL, urlBytes, fragRg.location - 1, kCFStringEncodingUTF8, NULL);
+        urlBytes.grow(numBytes);
+        CFURLGetBytes((CFURLRef)URL, urlBytes.data(), numBytes);
+    }
+
+    NSURL *result = (NSURL *)CFURLCreateWithBytes(NULL, urlBytes.data(), fragRg.location - 1, kCFStringEncodingUTF8, NULL);
     if (!result)
-        result = (NSURL *)CFURLCreateWithBytes(NULL, urlBytes, fragRg.location - 1, kCFStringEncodingISOLatin1, NULL);
+        result = (NSURL *)CFURLCreateWithBytes(NULL, urlBytes.data(), fragRg.location - 1, kCFStringEncodingISOLatin1, NULL);
         
-    if (urlBytes != buffer)
-        free(urlBytes);
     return result ? [result autorelease] : URL;
 }
 
@@ -877,32 +874,25 @@
 
 NSData *dataForURLComponentType(NSURL *URL, CFURLComponentType componentType)
 {
-    static const int URLComponentTypeBufferLength = 2048;
-    
-    UInt8 staticAllBytesBuffer[URLComponentTypeBufferLength];
-    UInt8 *allBytesBuffer = staticAllBytesBuffer;
-    
-    CFIndex bytesFilled = CFURLGetBytes((CFURLRef)URL, allBytesBuffer, URLComponentTypeBufferLength);
+    Vector<UInt8, URL_BYTES_BUFFER_LENGTH> allBytesBuffer(URL_BYTES_BUFFER_LENGTH);
+    CFIndex bytesFilled = CFURLGetBytes((CFURLRef)URL, allBytesBuffer.data(), allBytesBuffer.size());
     if (bytesFilled == -1) {
         CFIndex bytesToAllocate = CFURLGetBytes((CFURLRef)URL, NULL, 0);
-        allBytesBuffer = static_cast<UInt8 *>(malloc(bytesToAllocate));
-        bytesFilled = CFURLGetBytes((CFURLRef)URL, allBytesBuffer, bytesToAllocate);
+        allBytesBuffer.grow(bytesToAllocate);
+        bytesFilled = CFURLGetBytes((CFURLRef)URL, allBytesBuffer.data(), bytesToAllocate);
     }
     
     CFRange range;
     if (componentType != completeURL) {
         range = CFURLGetByteRangeForComponent((CFURLRef)URL, componentType, NULL);
-        if (range.location == kCFNotFound) {
-            if (staticAllBytesBuffer != allBytesBuffer)
-                free(allBytesBuffer);
+        if (range.location == kCFNotFound)
             return nil;
-        }
     } else {
         range.location = 0;
         range.length = bytesFilled;
     }
     
-    NSData *componentData = [NSData dataWithBytes:allBytesBuffer + range.location length:range.length]; 
+    NSData *componentData = [NSData dataWithBytes:allBytesBuffer.data() + range.location length:range.length]; 
     
     const unsigned char *bytes = static_cast<const unsigned char *>([componentData bytes]);
     NSMutableData *resultData = [NSMutableData data];
@@ -927,9 +917,6 @@
         }               
     }
     
-    if (staticAllBytesBuffer != allBytesBuffer)
-        free(allBytesBuffer);
-    
     return resultData;
 }
 
@@ -942,8 +929,8 @@
     // Remove one subsequent character.
     range.length++;
 
-    Vector<UInt8, 2048> buffer(2048);
-    CFIndex numBytes = CFURLGetBytes((CFURLRef)URL, buffer.data(), 2048);
+    Vector<UInt8, URL_BYTES_BUFFER_LENGTH> buffer(URL_BYTES_BUFFER_LENGTH);
+    CFIndex numBytes = CFURLGetBytes((CFURLRef)URL, buffer.data(), buffer.size());
     if (numBytes == -1) {
         numBytes = CFURLGetBytes((CFURLRef)URL, NULL, 0);
         buffer.grow(numBytes);
@@ -1010,10 +997,10 @@
 static CFStringRef createStringWithEscapedUnsafeCharacters(CFStringRef string)
 {
     CFIndex length = CFStringGetLength(string);
-    Vector<UChar, 2048> sourceBuffer(length);
+    Vector<UChar, URL_BYTES_BUFFER_LENGTH> sourceBuffer(length);
     CFStringGetCharacters(string, CFRangeMake(0, length), sourceBuffer.data());
     
-    Vector<UChar, 2048> outBuffer;
+    Vector<UChar, URL_BYTES_BUFFER_LENGTH> outBuffer;
     
     std::optional<UChar32> previousCodePoint;
     CFIndex i = 0;
@@ -1058,8 +1045,8 @@
     
     const unsigned char *p = before;
     int bufferLength = (length * 3) + 1;
-    char *after = static_cast<char *>(malloc(bufferLength)); // large enough to %-escape every character
-    char *q = after;
+    Vector<char, URL_BYTES_BUFFER_LENGTH> after(bufferLength); // large enough to %-escape every character
+    char *q = after.data();
     for (int i = 0; i < length; i++) {
         unsigned char c = p[i];
         // unescape escape sequences that indicate bytes greater than 0x7f
@@ -1086,7 +1073,7 @@
     *q = '\0';
     
     // Check string to see if it can be converted to display using UTF-8  
-    NSString *result = [NSString stringWithUTF8String:after];
+    NSString *result = [NSString stringWithUTF8String:after.data()];
     if (!result) {
         // Could not convert to UTF-8.
         // Convert characters greater than 0x7f to escape sequences.
@@ -1093,10 +1080,10 @@
         // Shift current string to the end of the buffer
         // then we will copy back bytes to the start of the buffer 
         // as we convert.
-        int afterlength = q - after;
-        char *p = after + bufferLength - afterlength - 1;
-        memmove(p, after, afterlength + 1); // copies trailing '\0'
-        char *q = after;
+        int afterlength = q - after.data();
+        char *p = after.data() + bufferLength - afterlength - 1;
+        memmove(p, after.data(), afterlength + 1); // copies trailing '\0'
+        char *q = after.data();
         while (*p) {
             unsigned char c = *p;
             if (c > 0x7f) {
@@ -1108,11 +1095,9 @@
             p++;
         }
         *q = '\0';
-        result = [NSString stringWithUTF8String:after];
+        result = [NSString stringWithUTF8String:after.data()];
     }
     
-    free(after);
-    
     if (mayNeedHostNameDecoding) {
         // FIXME: Is it good to ignore the failure of mapHostNames and keep result intact?
         NSString *mappedResult = mapHostNames(result, NO);

Modified: trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp (221582 => 221583)


--- trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp	2017-09-04 09:24:06 UTC (rev 221582)
+++ trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp	2017-09-04 09:24:21 UTC (rev 221583)
@@ -34,6 +34,7 @@
 #include <shlwapi.h>
 #include <wininet.h> // for INTERNET_MAX_URL_LENGTH
 #include <wtf/StringExtras.h>
+#include <wtf/Vector.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/StringBuilder.h>
 
@@ -277,11 +278,13 @@
     unsigned endFragmentOffset = startFragmentOffset + markupUTF8.length();
     unsigned endHTMLOffset = endFragmentOffset + strlen(endMarkup);
 
-    unsigned headerBufferLength = startHTMLOffset + 1; // + 1 for '\0' terminator.
-    char* headerBuffer = (char*)malloc(headerBufferLength);
-    snprintf(headerBuffer, headerBufferLength, header, startHTMLOffset, endHTMLOffset, startFragmentOffset, endFragmentOffset);
-    append(result, CString(headerBuffer));
-    free(headerBuffer);
+    {
+        unsigned headerBufferLength = startHTMLOffset + 1; // + 1 for '\0' terminator.
+        static const constexpr unsigned InitialBufferSize { 2048 };
+        Vector<char, InitialBufferSize> headerBuffer(headerBufferLength);
+        snprintf(headerBuffer.data(), headerBufferLength, header, startHTMLOffset, endHTMLOffset, startFragmentOffset, endFragmentOffset);
+        append(result, CString(headerBuffer.data()));
+    }
     if (sourceURLUTF8.length()) {
         append(result, sourceURLPrefix);
         append(result, sourceURLUTF8);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to