Changeset 53677 in webkit


Ignore:
Timestamp:
Jan 21, 2010 10:05:46 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-01-21 Kwang Yul Seo <skyul@company100.net>

Reviewed by Maciej Stachowiak.

Add fastStrDup to FastMalloc
https://bugs.webkit.org/show_bug.cgi?id=33937

The new string returned by fastStrDup is obtained with fastMalloc,
and can be freed with fastFree. This makes the memory management
more consistent because we don't need to keep strdup allocated pointers
and free them with free(). Instead we can use fastFree everywhere.

  • wtf/FastMalloc.cpp: (WTF::fastStrDup):
  • wtf/FastMalloc.h:
Location:
trunk/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r53672 r53677  
     12010-01-21  Kwang Yul Seo  <skyul@company100.net>
     2
     3        Reviewed by Maciej Stachowiak.
     4
     5        Add fastStrDup to FastMalloc
     6        https://bugs.webkit.org/show_bug.cgi?id=33937
     7
     8        The new string returned by fastStrDup is obtained with fastMalloc,
     9        and can be freed with fastFree. This makes the memory management
     10        more consistent because we don't need to keep strdup allocated pointers
     11        and free them with free(). Instead we can use fastFree everywhere.
     12
     13        * wtf/FastMalloc.cpp:
     14        (WTF::fastStrDup):
     15        * wtf/FastMalloc.h:
     16
    1172010-01-21  Brady Eidson  <beidson@apple.com>
    218
  • trunk/JavaScriptCore/wtf/FastMalloc.cpp

    r53584 r53677  
    180180    return result;
    181181}
     182
     183char* fastStrDup(const char* src)
     184{
     185    int len = strlen(src) + 1;
     186    char* dup = static_cast<char*>(fastMalloc(len));
     187
     188    if (dup)
     189        memcpy(dup, src, len);
     190
     191    return dup;
     192}
    182193   
    183194TryMallocReturnValue tryFastZeroedMalloc(size_t n)
  • trunk/JavaScriptCore/wtf/FastMalloc.h

    r52791 r53677  
    3434    void* fastCalloc(size_t numElements, size_t elementSize);
    3535    void* fastRealloc(void*, size_t);
     36    char* fastStrDup(const char*);
    3637
    3738    struct TryMallocReturnValue {
     
    189190using WTF::tryFastRealloc;
    190191using WTF::fastFree;
     192using WTF::fastStrDup;
    191193
    192194#ifndef NDEBUG   
Note: See TracChangeset for help on using the changeset viewer.