Changeset 274479 in webkit
- Timestamp:
- Mar 16, 2021, 8:05:21 AM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 12 edited
-
WTF/ChangeLog (modified) (1 diff)
-
WTF/wtf/FastMalloc.cpp (modified) (1 diff)
-
WTF/wtf/FastMalloc.h (modified) (2 diffs)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp (modified) (1 diff)
-
WebCore/platform/graphics/gstreamer/GStreamerCommon.h (modified) (1 diff)
-
WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp (modified) (1 diff)
-
WebCore/platform/mediastream/gstreamer/RealtimeIncomingAudioSourceLibWebRTC.cpp (modified) (2 diffs)
-
WebCore/platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/UIProcess/API/glib/WebKitWebResource.cpp (modified) (1 diff)
-
WebKit/UIProcess/API/glib/WebKitWebView.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r274476 r274479 1 2021-03-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK][WPE] Stop using g_memdup 4 https://bugs.webkit.org/show_bug.cgi?id=223189 5 6 Reviewed by Philippe Normand. 7 8 Add fastMemDup() to replace g_memdup() that is now deprecated in GLib because of the possibility of overflow 9 when converting from size_t to unsigned int. There's a replacement in GLib already, but we would need to depend 10 on very new GLib version, so better use fastMemDup() when possible. In cases where we still need to use GLib 11 allocator, we can simply call g_malloc() + memcpy(). 12 13 * wtf/FastMalloc.cpp: 14 (WTF::fastMemDup): 15 * wtf/FastMalloc.h: 16 1 17 2021-03-16 Khem Raj <raj.khem@gmail.com> 2 18 -
trunk/Source/WTF/wtf/FastMalloc.cpp
r265735 r274479 98 98 } 99 99 100 void* fastMemDup(const void* mem, size_t bytes) 101 { 102 if (!mem || !bytes) 103 return nullptr; 104 105 void* result = fastMalloc(bytes); 106 memcpy(result, mem, bytes); 107 return result; 108 } 109 100 110 TryMallocReturnValue tryFastZeroedMalloc(size_t n) 101 111 { -
trunk/Source/WTF/wtf/FastMalloc.h
r260409 r274479 94 94 WTF_EXPORT_PRIVATE void* fastRealloc(void*, size_t) RETURNS_NONNULL; 95 95 WTF_EXPORT_PRIVATE char* fastStrDup(const char*) RETURNS_NONNULL; 96 WTF_EXPORT_PRIVATE void* fastMemDup(const void*, size_t); 96 97 97 98 WTF_EXPORT_PRIVATE TryMallocReturnValue tryFastMalloc(size_t); … … 309 310 using WTF::fastMallocGoodSize; 310 311 using WTF::fastMallocSize; 312 using WTF::fastMemDup; 311 313 using WTF::fastRealloc; 312 314 using WTF::fastStrDup; -
trunk/Source/WebCore/ChangeLog
r274478 r274479 1 2021-03-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK][WPE] Stop using g_memdup 4 https://bugs.webkit.org/show_bug.cgi?id=223189 5 6 Reviewed by Philippe Normand. 7 8 Add gstBufferNewWrappedFast() to create a GstBuffer wrapping data allocated with fast malloc and use it when 9 possible in combination with fastMemDup() instead of g_memdup(). 10 11 * platform/graphics/gstreamer/GStreamerCommon.cpp: 12 (WebCore::gstBufferNewWrappedFast): 13 * platform/graphics/gstreamer/GStreamerCommon.h: 14 * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp: 15 (CachedResourceStreamingClient::dataReceived): 16 * platform/mediastream/gstreamer/RealtimeIncomingAudioSourceLibWebRTC.cpp: 17 (WebCore::RealtimeIncomingAudioSourceLibWebRTC::OnData): 18 * platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp: 19 1 20 2021-03-16 Xabier Rodriguez Calvar <calvaris@igalia.com> 2 21 -
trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp
r273311 r274479 504 504 } 505 505 506 GstBuffer* gstBufferNewWrappedFast(void* data, size_t length) 507 { 508 return gst_buffer_new_wrapped_full(static_cast<GstMemoryFlags>(0), data, length, 0, length, data, fastFree); 509 } 510 506 511 } 507 512 -
trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h
r271512 r274479 301 301 }); 302 302 303 GstBuffer* gstBufferNewWrappedFast(void* data, size_t length); 304 303 305 } 304 306 -
trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
r273731 r274479 1127 1127 checkUpdateBlocksize(length); 1128 1128 1129 GstBuffer* buffer = gst _buffer_new_wrapped(g_memdup(data, length), length);1129 GstBuffer* buffer = gstBufferNewWrappedFast(fastMemDup(data, length), length); 1130 1130 gst_adapter_push(members->adapter.get(), buffer); 1131 1131 stopLoaderIfNeeded(src, members); -
trunk/Source/WebCore/platform/mediastream/gstreamer/RealtimeIncomingAudioSourceLibWebRTC.cpp
r269849 r274479 66 66 67 67 auto bufferSize = GST_AUDIO_INFO_BPF(&info) * numberOfFrames; 68 gpointer bufferData = g_malloc(bufferSize);68 gpointer bufferData = fastMalloc(bufferSize); 69 69 if (muted()) 70 70 gst_audio_format_fill_silence(info.finfo, bufferData, bufferSize); … … 72 72 memcpy(bufferData, audioData, bufferSize); 73 73 74 auto buffer = adoptGRef(gst _buffer_new_wrapped(bufferData, bufferSize));74 auto buffer = adoptGRef(gstBufferNewWrappedFast(bufferData, bufferSize)); 75 75 auto caps = adoptGRef(gst_audio_info_to_caps(&info)); 76 76 auto sample = adoptGRef(gst_sample_new(buffer.get(), caps.get(), nullptr, nullptr)); -
trunk/Source/WebCore/platform/mediastream/libwebrtc/GStreamerVideoDecoderFactory.cpp
r273951 r274479 214 214 215 215 // FIXME- Use a GstBufferPool. 216 auto buffer = adoptGRef(gst _buffer_new_wrapped(g_memdup(inputImage.data(), inputImage.size()),216 auto buffer = adoptGRef(gstBufferNewWrappedFast(fastMemDup(inputImage.data(), inputImage.size()), 217 217 inputImage.size())); 218 218 GST_BUFFER_DTS(buffer.get()) = (static_cast<guint64>(inputImage.Timestamp()) * GST_MSECOND) - m_firstBufferDts; -
trunk/Source/WebKit/ChangeLog
r274476 r274479 1 2021-03-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK][WPE] Stop using g_memdup 4 https://bugs.webkit.org/show_bug.cgi?id=223189 5 6 Reviewed by Philippe Normand. 7 8 * UIProcess/API/glib/WebKitWebResource.cpp: 9 (webkit_web_resource_get_data_finish): Use g_malloc + memcpy instead of g_memdup. 10 * UIProcess/API/glib/WebKitWebView.cpp: 11 (webkit_web_view_save_finish): Use fastMemDup instead g_memdup. 12 1 13 2021-03-16 Khem Raj <raj.khem@gmail.com> 2 14 -
trunk/Source/WebKit/UIProcess/API/glib/WebKitWebResource.cpp
r272991 r274479 402 402 guchar* webkit_web_resource_get_data_finish(WebKitWebResource* resource, GAsyncResult* result, gsize* length, GError** error) 403 403 { 404 g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(resource), 0);405 g_return_val_if_fail(g_task_is_valid(result, resource), 0);404 g_return_val_if_fail(WEBKIT_IS_WEB_RESOURCE(resource), nullptr); 405 g_return_val_if_fail(g_task_is_valid(result, resource), nullptr); 406 406 407 407 GTask* task = G_TASK(result); 408 408 if (!g_task_propagate_boolean(task, error)) 409 return 0;409 return nullptr; 410 410 411 411 ResourceGetDataAsyncData* data = static_cast<ResourceGetDataAsyncData*>(g_task_get_task_data(task)); 412 412 if (length) 413 413 *length = data->webData->size(); 414 return static_cast<guchar*>(g_memdup(data->webData->bytes(), data->webData->size())); 415 } 414 415 auto* bytes = data->webData->bytes(); 416 if (!bytes || !data->webData->size()) 417 return nullptr; 418 419 auto* returnValue = g_malloc(data->webData->size()); 420 memcpy(returnValue, bytes, data->webData->size()); 421 return static_cast<guchar*>(returnValue); 422 } -
trunk/Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp
r272636 r274479 4197 4197 gsize length = data->webData->size(); 4198 4198 if (length) 4199 g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(dataStream), g_memdup(data->webData->bytes(), length), length, g_free);4199 g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(dataStream), fastMemDup(data->webData->bytes(), length), length, fastFree); 4200 4200 4201 4201 return dataStream;
Note:
See TracChangeset
for help on using the changeset viewer.