From e2752f8e85f9af0811ef68dad83832f6f5d6c022 Mon Sep 17 00:00:00 2001
From: Leif Walsh <leif@tokutek.com>
Date: Wed, 17 Apr 2013 00:01:10 -0400
Subject: [PATCH] refs #5368 make some lock tree tests use the memory.h api

git-svn-id: file:///svn/toku/tokudb@48324 c7de825b-a66e-492c-adef-691d508d4ae1
---
 .../tests/test_footprint_point_write.cc       | 23 +++----------------
 .../tests/test_footprint_range_write.cc       | 23 +++----------------
 2 files changed, 6 insertions(+), 40 deletions(-)

diff --git a/src/lock_tree/tests/test_footprint_point_write.cc b/src/lock_tree/tests/test_footprint_point_write.cc
index d553ffee6b..42b3ea9f91 100644
--- a/src/lock_tree/tests/test_footprint_point_write.cc
+++ b/src/lock_tree/tests/test_footprint_point_write.cc
@@ -13,17 +13,9 @@
 #ifndef TOKU_ALLOW_DEPRECATED
 #define TOKU_ALLOW_DEPRECATED
 #endif
-#if defined(HAVE_MALLOC_H)
-# include <malloc.h>
-#elif defined(HAVE_SYS_MALLOC_H)
-# include <sys/malloc.h>
-# if defined(HAVE_MALLOC_MALLOC_H)
-#  include <malloc/malloc.h>
-# endif
-#endif
 #include "test.h"
+#include <memory.h>
 #include <toku_byteswap.h>
-#include <dlfcn.h>
 
 static uint64_t htonl64(uint64_t x) {
 #if BYTE_ORDER == LITTLE_ENDIAN
@@ -33,15 +25,6 @@ static uint64_t htonl64(uint64_t x) {
 #endif
 }
 
-#if defined(HAVE_MALLOC_USABLE_SIZE)
-typedef size_t (*malloc_usable_size_fun_t)(void *p);
-size_t malloc_usable_size(void *p) __THROW;
-static malloc_usable_size_fun_t malloc_usable_size_f = malloc_usable_size;
-#elif defined(HAVE_MALLOC_SIZE)
-typedef size_t (*malloc_usable_size_fun_t)(const void *p);
-static malloc_usable_size_fun_t malloc_usable_size_f = malloc_size;
-#endif
-
 struct my_ltm_status {
     uint32_t max_locks, curr_locks;
     uint64_t max_lock_memory, curr_lock_memory;
@@ -59,7 +42,7 @@ static void my_ltm_get_status(toku_ltm *ltm, struct my_ltm_status *my_status) {
 static void *my_malloc(size_t s) {
     void * p = malloc(s);
     if (verbose) 
-        printf("%s %lu %lu\n", __FUNCTION__, s, malloc_usable_size_f(p));
+        printf("%s %lu %lu\n", __FUNCTION__, s, toku_malloc_usable_size(p));
     return p;
 }
 
@@ -71,7 +54,7 @@ static void *my_realloc(void *p, size_t s) {
 
 static void my_free(void *p) {
     if (verbose) 
-        printf("%s %p %lu\n", __FUNCTION__, p, malloc_usable_size_f(p));
+        printf("%s %p %lu\n", __FUNCTION__, p, toku_malloc_usable_size(p));
     free(p);
 }
 
diff --git a/src/lock_tree/tests/test_footprint_range_write.cc b/src/lock_tree/tests/test_footprint_range_write.cc
index dc5d05aa3f..925ef9cbe8 100644
--- a/src/lock_tree/tests/test_footprint_range_write.cc
+++ b/src/lock_tree/tests/test_footprint_range_write.cc
@@ -13,17 +13,9 @@
 #ifndef TOKU_ALLOW_DEPRECATED
 #define TOKU_ALLOW_DEPRECATED
 #endif
-#if defined(HAVE_MALLOC_H)
-# include <malloc.h>
-#elif defined(HAVE_SYS_MALLOC_H)
-# include <sys/malloc.h>
-# if defined(HAVE_MALLOC_MALLOC_H)
-#  include <malloc/malloc.h>
-# endif
-#endif
 #include "test.h"
+#include <memory.h>
 #include <toku_byteswap.h>
-#include <dlfcn.h>
 
 static uint64_t htonl64(uint64_t x) {
 #if BYTE_ORDER == LITTLE_ENDIAN
@@ -33,15 +25,6 @@ static uint64_t htonl64(uint64_t x) {
 #endif
 }
 
-#if defined(HAVE_MALLOC_USABLE_SIZE)
-typedef size_t (*malloc_usable_size_fun_t)(void *p);
-size_t malloc_usable_size(void *p) __THROW;
-static malloc_usable_size_fun_t malloc_usable_size_f = malloc_usable_size;
-#elif defined(HAVE_MALLOC_SIZE)
-typedef size_t (*malloc_usable_size_fun_t)(const void *p);
-static malloc_usable_size_fun_t malloc_usable_size_f = malloc_size;
-#endif
-
 struct my_ltm_status {
     uint32_t max_locks, curr_locks;
     uint64_t max_lock_memory, curr_lock_memory;
@@ -59,7 +42,7 @@ static void my_ltm_get_status(toku_ltm *ltm, struct my_ltm_status *my_status) {
 static void *my_malloc(size_t s) {
     void * p = malloc(s);
     if (verbose) 
-        printf("%s %lu %lu\n", __FUNCTION__, s, malloc_usable_size_f(p));
+        printf("%s %lu %lu\n", __FUNCTION__, s, toku_malloc_usable_size(p));
     return p;
 }
 
@@ -71,7 +54,7 @@ static void *my_realloc(void *p, size_t s) {
 
 static void my_free(void *p) {
     if (verbose) 
-        printf("%s %p %lu\n", __FUNCTION__, p, malloc_usable_size_f(p));
+        printf("%s %p %lu\n", __FUNCTION__, p, toku_malloc_usable_size(p));
     free(p);
 }
 
-- 
2.30.9