summaryrefslogtreecommitdiffstats
path: root/third_party
diff options
context:
space:
mode:
authormbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-08 07:53:54 +0000
committermbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-08 07:53:54 +0000
commit5b711531e12ec0d54b2a8cab660dfbac04e70ab6 (patch)
treefac5fc568e5a487ab53d82a7638d821108c8864d /third_party
parent1cda29e91ff949440ee93675241ee8e1e9e8ab10 (diff)
downloadchromium_src-5b711531e12ec0d54b2a8cab660dfbac04e70ab6.zip
chromium_src-5b711531e12ec0d54b2a8cab660dfbac04e70ab6.tar.gz
chromium_src-5b711531e12ec0d54b2a8cab660dfbac04e70ab6.tar.bz2
Fix the windows allocator to behave properly on realloc.
The spec says that calling realloc(ptr, 0) should free ptr and return NULL. BUG=none TEST=none Review URL: http://codereview.chromium.org/196041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25612 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r--third_party/tcmalloc/win_allocator.cc24
1 files changed, 14 insertions, 10 deletions
diff --git a/third_party/tcmalloc/win_allocator.cc b/third_party/tcmalloc/win_allocator.cc
index d2207f6..8ae653a 100644
--- a/third_party/tcmalloc/win_allocator.cc
+++ b/third_party/tcmalloc/win_allocator.cc
@@ -25,22 +25,26 @@ bool win_heap_init(bool use_lfh) {
return true;
}
-void* win_heap_malloc(size_t s) {
- return HeapAlloc(win_heap, 0, s);
+void* win_heap_malloc(size_t size) {
+ return HeapAlloc(win_heap, 0, size);
}
-void* win_heap_realloc(void* p, size_t s) {
- if (!p)
- return win_heap_malloc(s);
- return HeapReAlloc(win_heap, 0, p, s);
+void win_heap_free(void* size) {
+ HeapFree(win_heap, 0, size);
}
-void win_heap_free(void* s) {
- HeapFree(win_heap, 0, s);
+void* win_heap_realloc(void* ptr, size_t size) {
+ if (!ptr)
+ return win_heap_malloc(size);
+ if (!size) {
+ win_heap_free(ptr);
+ return NULL;
+ }
+ return HeapReAlloc(win_heap, 0, ptr, size);
}
-size_t win_heap_msize(void* p) {
- return HeapSize(win_heap, 0, p);
+size_t win_heap_msize(void* ptr) {
+ return HeapSize(win_heap, 0, ptr);
}
} // extern "C"