Ignore:
Timestamp:
Jan 21, 2010, 10:05:46 PM (15 years ago)
Author:
[email protected]
Message:

2010-01-21 Kwang Yul Seo <[email protected]>

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:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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)
Note: See TracChangeset for help on using the changeset viewer.