diff options
| author | Michael Bebenita <mbebenita@mozilla.com> | 2010-07-27 23:10:31 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2010-07-28 20:30:28 -0700 |
| commit | 6afb6c767ed3274359bcac5af5a11851922e3668 (patch) | |
| tree | 090572a274b2c860878863c725bfe93ffad48d52 /src/rt/rust.cpp | |
| parent | 712249d6b8f3c4f08514c5917effcbced0f0477a (diff) | |
| download | rust-6afb6c767ed3274359bcac5af5a11851922e3668.tar.gz rust-6afb6c767ed3274359bcac5af5a11851922e3668.zip | |
Move allocation-tracking into rust_srv.
Diffstat (limited to 'src/rt/rust.cpp')
| -rw-r--r-- | src/rt/rust.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/rt/rust.cpp b/src/rt/rust.cpp index 00e709c9748..37398655190 100644 --- a/src/rt/rust.cpp +++ b/src/rt/rust.cpp @@ -1,13 +1,12 @@ #include "rust_internal.h" -#include "util/array_list.h" -// #define TRACK_ALLOCATIONS +#define TRACK_ALLOCATIONS // For debugging, keeps track of live allocations, so you can find out // exactly what leaked. -#ifdef TRACK_ALLOCATIONS -array_list<void *> allocation_list; -#endif +//#ifdef TRACK_ALLOCATIONS +//array_list<void *> allocation_list; +//#endif rust_srv::rust_srv() : live_allocs(0) @@ -70,16 +69,18 @@ rust_srv::realloc(void *p, size_t bytes) void rust_srv::free(void *p) { - if (live_allocs < 1) { - fatal("live_allocs < 1", __FILE__, __LINE__); - } - live_allocs--; - ::free(p); #ifdef TRACK_ALLOCATIONS if (allocation_list.replace(p, NULL) == NULL) { + printf("ptr 0x%" PRIxPTR " is not in allocation_list\n", + (uintptr_t) p); fatal("not in allocation_list", __FILE__, __LINE__); } #endif + if (live_allocs < 1) { + fatal("live_allocs < 1", __FILE__, __LINE__); + } + live_allocs--; + ::free(p); } void |
