From b883d6a54c460f8357b1107b3599108eb1f8580b Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sat, 29 Jun 2013 22:35:04 -0400 Subject: simplify the exchange allocator * stop using an atomic counter, this has a significant cost and valgrind will already catch these leaks * remove the extra layer of function calls * remove the assert of non-null in free, freeing null is well defined but throwing a failure from free will not be * stop initializing the `prev`/`next` pointers * abort on out-of-memory, failing won't necessarily work --- src/rt/rust_exchange_alloc.cpp | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'src/rt/rust_exchange_alloc.cpp') diff --git a/src/rt/rust_exchange_alloc.cpp b/src/rt/rust_exchange_alloc.cpp index 89257dc9f6e..658d97031ce 100644 --- a/src/rt/rust_exchange_alloc.cpp +++ b/src/rt/rust_exchange_alloc.cpp @@ -15,16 +15,10 @@ #include #include -extern uintptr_t rust_exchange_count; -uintptr_t rust_exchange_count = 0; - void * rust_exchange_alloc::malloc(size_t size) { void *value = ::malloc(size); assert(value); - - sync::increment(rust_exchange_count); - return value; } @@ -37,15 +31,5 @@ rust_exchange_alloc::realloc(void *ptr, size_t size) { void rust_exchange_alloc::free(void *ptr) { - sync::decrement(rust_exchange_count); ::free(ptr); } - -void -rust_check_exchange_count_on_exit() { - if (rust_exchange_count != 0) { - printf("exchange heap not empty on exit\n"); - printf("%d dangling allocations\n", (int)rust_exchange_count); - abort(); - } -} -- cgit 1.4.1-3-g733a5