Replace strdup with base::Strdup
The Cobalt team uses base/wrappers.h to intercept some low level OS functions and recently we found strdup to be a blocker. Thankfully it only appeared once in V8. Change-Id: Ib20f399f94933b5d407c1e22e1df674420003ba2 Bug: v8:10927 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2963805 Auto-Submit: John Xu <johnx@google.com> Commit-Queue: John Xu <johnx@google.com> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/master@{#75171}
This commit is contained in:
parent
a52858dc01
commit
7956f9521f
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#if defined(V8_OS_STARBOARD)
|
#if defined(V8_OS_STARBOARD)
|
||||||
#include "starboard/memory.h"
|
#include "starboard/memory.h"
|
||||||
|
#include "starboard/string.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace v8 {
|
namespace v8 {
|
||||||
@ -33,6 +34,8 @@ inline void Free(void* memory) { return free(memory); }
|
|||||||
|
|
||||||
inline void* Calloc(size_t count, size_t size) { return calloc(count, size); }
|
inline void* Calloc(size_t count, size_t size) { return calloc(count, size); }
|
||||||
|
|
||||||
|
inline char* Strdup(const char* source) { return strdup(source); }
|
||||||
|
|
||||||
inline FILE* Fopen(const char* filename, const char* mode) {
|
inline FILE* Fopen(const char* filename, const char* mode) {
|
||||||
return fopen(filename, mode);
|
return fopen(filename, mode);
|
||||||
}
|
}
|
||||||
@ -41,7 +44,7 @@ inline int Fclose(FILE* stream) { return fclose(stream); }
|
|||||||
|
|
||||||
#else // V8_OS_STARBOARD
|
#else // V8_OS_STARBOARD
|
||||||
|
|
||||||
inline void* Malloc(size_t size) { return SbMemoryAlloc(size); }
|
inline void* Malloc(size_t size) { return SbMemoryAllocate(size); }
|
||||||
|
|
||||||
inline void* Realloc(void* memory, size_t size) {
|
inline void* Realloc(void* memory, size_t size) {
|
||||||
return SbMemoryReallocate(memory, size);
|
return SbMemoryReallocate(memory, size);
|
||||||
@ -53,6 +56,8 @@ inline void* Calloc(size_t count, size_t size) {
|
|||||||
return SbMemoryCalloc(count, size);
|
return SbMemoryCalloc(count, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline char* Strdup(const char* source) { return SbStringDuplicate(source); }
|
||||||
|
|
||||||
inline FILE* Fopen(const char* filename, const char* mode) { return NULL; }
|
inline FILE* Fopen(const char* filename, const char* mode) { return NULL; }
|
||||||
|
|
||||||
inline int Fclose(FILE* stream) { return -1; }
|
inline int Fclose(FILE* stream) { return -1; }
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "include/libplatform/v8-tracing.h"
|
#include "include/libplatform/v8-tracing.h"
|
||||||
|
|
||||||
#include "src/base/atomicops.h"
|
#include "src/base/atomicops.h"
|
||||||
#include "src/base/platform/mutex.h"
|
#include "src/base/platform/mutex.h"
|
||||||
#include "src/base/platform/time.h"
|
#include "src/base/platform/time.h"
|
||||||
|
#include "src/base/platform/wrappers.h"
|
||||||
|
|
||||||
#ifdef V8_USE_PERFETTO
|
#ifdef V8_USE_PERFETTO
|
||||||
#include "perfetto/ext/trace_processor/export_json.h"
|
#include "perfetto/ext/trace_processor/export_json.h"
|
||||||
@ -325,7 +325,7 @@ const uint8_t* TracingController::GetCategoryGroupEnabled(
|
|||||||
// Don't hold on to the category_group pointer, so that we can create
|
// Don't hold on to the category_group pointer, so that we can create
|
||||||
// category groups with strings not known at compile time (this is
|
// category groups with strings not known at compile time (this is
|
||||||
// required by SetWatchEvent).
|
// required by SetWatchEvent).
|
||||||
const char* new_group = strdup(category_group);
|
const char* new_group = base::Strdup(category_group);
|
||||||
g_category_groups[category_index] = new_group;
|
g_category_groups[category_index] = new_group;
|
||||||
DCHECK(!g_category_group_enabled[category_index]);
|
DCHECK(!g_category_group_enabled[category_index]);
|
||||||
// Note that if both included and excluded patterns in the
|
// Note that if both included and excluded patterns in the
|
||||||
|
Loading…
Reference in New Issue
Block a user