[webkit-dev] strdup in WebKit
Maciej Stachowiak
mjs at apple.com
Wed Jan 20 03:24:35 PST 2010
On Jan 20, 2010, at 2:07 AM, KwangYul Seo wrote:
> Hi,
>
> WebKit does not use malloc/free directly in favor of fastMalloc/fastFree. The only exception to this rule is strdup() which returns a memory that must be freed by free. Why don't we add fastStrDup which allocates a memory with fastMalloc? The memory returned by fastStrDup can be freed by fastFree.
Sounds like a reasonable plan in general. It's possible that in some of the cases you cie below, strdup is being used to pass malloc-allocated memory to a library that expects a string allocated with system malloc, which it will proceed to free itself. I'm not sure if it's really true in any of these cases, but it's something to check.
I suggest filing a bug and submitting a patch for this.
Cheers,
Maciej
>
> The following source files in WebCore contains strdup calls.
>
> dom/XMLTokenizerLibxml2.cpp
> plugins/PluginStream.cpp
> platform/network/ResourceHandleInternal.h
> platform/network/curl/ResourceHandleManager.cpp
> platform/network/curl/ResourceHandleCurl.cpp
> xml/XSLTProcessorLibxslt.cpp
> bindings/v8/npruntime.cpp
> bindings/v8/V8NPUtils.cpp
> bridge/IdentifierRep.h
> bridge/jni/jni_runtime.cpp
> bridge/jni/jsc/JavaClassJSC.cpp
> bridge/npruntime.cpp
> bridge/testbindings.cpp
>
> strdup/free pairs can be safely replaced with fastStrDup/fastFree in most cases. However, bridge and bindings can be an exception because some APIs must return malloc() allocated memory that can be freed with free().
>
> I am asking this because strdup (POSIX function) is not available in RVCT. If this is not possible for some reasons, adding strdup to StringExtras.h for RVCT can be a good solution too. How does the Symbian QT port solve this problem?
>
> Regards,
> Kwang Yul Seo
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20100120/68011e65/attachment.html>
More information about the webkit-dev
mailing list