Commit 4d234861 authored by Zardosht Kasheff's avatar Zardosht Kasheff

closes #77, remove tabs from memory.cc

parent bbee1fec
...@@ -192,12 +192,12 @@ my_malloc_usable_size(void *p) { ...@@ -192,12 +192,12 @@ my_malloc_usable_size(void *p) {
static inline void static inline void
set_max(uint64_t sum_used, uint64_t sum_freed) { set_max(uint64_t sum_used, uint64_t sum_freed) {
if (sum_used >= sum_freed) { if (sum_used >= sum_freed) {
uint64_t in_use = sum_used - sum_freed; uint64_t in_use = sum_used - sum_freed;
uint64_t old_max; uint64_t old_max;
do { do {
old_max = status.max_in_use; old_max = status.max_in_use;
} while (old_max < in_use && } while (old_max < in_use &&
!toku_sync_bool_compare_and_swap(&status.max_in_use, old_max, in_use)); !toku_sync_bool_compare_and_swap(&status.max_in_use, old_max, in_use));
} }
} }
...@@ -206,14 +206,14 @@ toku_memory_footprint(void * p, size_t touched) { ...@@ -206,14 +206,14 @@ toku_memory_footprint(void * p, size_t touched) {
size_t rval = 0; size_t rval = 0;
size_t pagesize = toku_os_get_pagesize(); size_t pagesize = toku_os_get_pagesize();
if (p) { if (p) {
size_t usable = my_malloc_usable_size(p); size_t usable = my_malloc_usable_size(p);
if (usable >= status.mmap_threshold) { if (usable >= status.mmap_threshold) {
int num_pages = (touched + pagesize) / pagesize; int num_pages = (touched + pagesize) / pagesize;
rval = num_pages * pagesize; rval = num_pages * pagesize;
} }
else { else {
rval = usable; rval = usable;
} }
} }
return rval; return rval;
} }
...@@ -222,7 +222,7 @@ void * ...@@ -222,7 +222,7 @@ void *
toku_malloc(size_t size) { toku_malloc(size_t size) {
void *p = t_malloc ? t_malloc(size) : os_malloc(size); void *p = t_malloc ? t_malloc(size) : os_malloc(size);
if (p) { if (p) {
TOKU_ANNOTATE_NEW_MEMORY(p, size); // see #4671 and https://bugs.kde.org/show_bug.cgi?id=297147 TOKU_ANNOTATE_NEW_MEMORY(p, size); // see #4671 and https://bugs.kde.org/show_bug.cgi?id=297147
if (toku_memory_do_stats) { if (toku_memory_do_stats) {
size_t used = my_malloc_usable_size(p); size_t used = my_malloc_usable_size(p);
toku_sync_add_and_fetch(&status.malloc_count, 1); toku_sync_add_and_fetch(&status.malloc_count, 1);
...@@ -239,7 +239,7 @@ toku_malloc(size_t size) { ...@@ -239,7 +239,7 @@ toku_malloc(size_t size) {
void *toku_malloc_aligned(size_t alignment, size_t size) { void *toku_malloc_aligned(size_t alignment, size_t size) {
void *p = t_malloc_aligned ? t_malloc_aligned(alignment, size) : os_malloc_aligned(alignment, size); void *p = t_malloc_aligned ? t_malloc_aligned(alignment, size) : os_malloc_aligned(alignment, size);
if (p) { if (p) {
TOKU_ANNOTATE_NEW_MEMORY(p, size); // see #4671 and https://bugs.kde.org/show_bug.cgi?id=297147 TOKU_ANNOTATE_NEW_MEMORY(p, size); // see #4671 and https://bugs.kde.org/show_bug.cgi?id=297147
if (toku_memory_do_stats) { if (toku_memory_do_stats) {
size_t used = my_malloc_usable_size(p); size_t used = my_malloc_usable_size(p);
toku_sync_add_and_fetch(&status.malloc_count, 1); toku_sync_add_and_fetch(&status.malloc_count, 1);
...@@ -275,7 +275,7 @@ toku_realloc(void *p, size_t size) { ...@@ -275,7 +275,7 @@ toku_realloc(void *p, size_t size) {
set_max(status.used, status.freed); set_max(status.used, status.freed);
} }
} else { } else {
toku_sync_add_and_fetch(&status.realloc_fail, 1); toku_sync_add_and_fetch(&status.realloc_fail, 1);
} }
return q; return q;
} }
...@@ -293,7 +293,7 @@ void *toku_realloc_aligned(size_t alignment, void *p, size_t size) { ...@@ -293,7 +293,7 @@ void *toku_realloc_aligned(size_t alignment, void *p, size_t size) {
set_max(status.used, status.freed); set_max(status.used, status.freed);
} }
} else { } else {
toku_sync_add_and_fetch(&status.realloc_fail, 1); toku_sync_add_and_fetch(&status.realloc_fail, 1);
} }
return q; return q;
} }
...@@ -319,10 +319,10 @@ toku_free(void *p) { ...@@ -319,10 +319,10 @@ toku_free(void *p) {
toku_sync_add_and_fetch(&status.free_count, 1); toku_sync_add_and_fetch(&status.free_count, 1);
toku_sync_add_and_fetch(&status.freed, used); toku_sync_add_and_fetch(&status.freed, used);
} }
if (t_free) if (t_free)
t_free(p); t_free(p);
else else
os_free(p); os_free(p);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment