Reviewers: Yang,
Description:
Avoid memset(NULL, ...).
Please review this at https://codereview.chromium.org/290453003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+4, -2 lines):
M samples/shell.cc
M src/d8.cc
Index: samples/shell.cc
diff --git a/samples/shell.cc b/samples/shell.cc
index
e9f99896e9c3ada9afdbfa263cd0c419e54ee88f..aebe49d49e7763038bb840e93bc3d5a290a43de8
100644
--- a/samples/shell.cc
+++ b/samples/shell.cc
@@ -68,7 +68,8 @@ static bool run_shell;
class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
public:
virtual void* Allocate(size_t length) {
- return memset(AllocateUninitialized(length), 0, length);
+ void* data = AllocateUninitialized(length);
+ return data == NULL ? data : memset(data, 0, length);
}
virtual void* AllocateUninitialized(size_t length) { return
malloc(length); }
virtual void Free(void* data, size_t) { free(data); }
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index
8ea77fdb1b9313943bdbf7f6ef99a0c6c5040291..502187a9a70d9d9437689d4c98df7104910a3666
100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -1450,7 +1450,8 @@ static void DumpHeapConstants(i::Isolate* isolate) {
class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
public:
virtual void* Allocate(size_t length) {
- return memset(AllocateUninitialized(length), 0, length);
+ void* data = AllocateUninitialized(length);
+ return data == NULL ? data : memset(data, 0, length);
}
virtual void* AllocateUninitialized(size_t length) { return
malloc(length); }
virtual void Free(void* data, size_t) { free(data); }
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.