Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: src/d8.cc

Issue 290453003: Avoid memset(NULL, ...). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/shell.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 5
6 // Defined when linking against shared lib on Windows. 6 // Defined when linking against shared lib on Windows.
7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED)
8 #define V8_SHARED 8 #define V8_SHARED
9 #endif 9 #endif
10 10
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 } 1443 }
1444 printf("}\n"); 1444 printf("}\n");
1445 #undef ROOT_LIST_CASE 1445 #undef ROOT_LIST_CASE
1446 } 1446 }
1447 #endif // !V8_SHARED 1447 #endif // !V8_SHARED
1448 1448
1449 1449
1450 class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator { 1450 class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
1451 public: 1451 public:
1452 virtual void* Allocate(size_t length) { 1452 virtual void* Allocate(size_t length) {
1453 return memset(AllocateUninitialized(length), 0, length); 1453 void* data = AllocateUninitialized(length);
1454 return data == NULL ? data : memset(data, 0, length);
1454 } 1455 }
1455 virtual void* AllocateUninitialized(size_t length) { return malloc(length); } 1456 virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
1456 virtual void Free(void* data, size_t) { free(data); } 1457 virtual void Free(void* data, size_t) { free(data); }
1457 }; 1458 };
1458 1459
1459 1460
1460 class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator { 1461 class MockArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
1461 public: 1462 public:
1462 virtual void* Allocate(size_t) V8_OVERRIDE { 1463 virtual void* Allocate(size_t) V8_OVERRIDE {
1463 return malloc(0); 1464 return malloc(0);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 } 1556 }
1556 1557
1557 } // namespace v8 1558 } // namespace v8
1558 1559
1559 1560
1560 #ifndef GOOGLE3 1561 #ifndef GOOGLE3
1561 int main(int argc, char* argv[]) { 1562 int main(int argc, char* argv[]) {
1562 return v8::Shell::Main(argc, argv); 1563 return v8::Shell::Main(argc, argv);
1563 } 1564 }
1564 #endif 1565 #endif
OLDNEW
« no previous file with comments | « samples/shell.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698