diff --git a/newbrt/memory.c b/newbrt/memory.c index 49b30af90ca..1a139a0b362 100644 --- a/newbrt/memory.c +++ b/newbrt/memory.c @@ -10,164 +10,14 @@ int toku_memory_check=0; -#define WHEN_MEM_DEBUG(x) ({if (toku_memory_check) ({x});}) - - -static long long n_items_malloced=0; - -/* Memory checking */ -enum { items_limit = 1000 }; -static int overflowed=0; -static void *items[items_limit]; -static long sizes[items_limit]; - -static void note_did_malloc (void *p, size_t size) { - static long long count=0; - WHEN_MEM_DEBUG( - if (n_items_malloced%p\n", __FILE__, __LINE__, nmemb, size, r); - note_did_malloc(r, nmemb*size); - //if ((long)r==0x80523f8) { printf("%s:%d %p\n", __FILE__, __LINE__, r); } - return r; + return calloc(nmemb, size); } -#define FREELIST_LIMIT (64+1) -static void *freelist[FREELIST_LIMIT]; -#define MALLOC_SIZE_COUNTING_LIMIT 512 -static int malloc_counts[MALLOC_SIZE_COUNTING_LIMIT]; // We rely on static variables being initialized to 0. -static int fresh_malloc_counts[MALLOC_SIZE_COUNTING_LIMIT]; // We rely on static variables being initialized to 0. -static int other_malloc_count=0, fresh_other_malloc_count=0; void *toku_malloc(size_t size) { - void * r; - errno=0; - if (size=sizeof(void*) && size%p (%lld)\n", __FILE__, __LINE__, size,r, n_items_malloced); - //if ((long)r==0x80523f8) { printf("%s:%d %p size=%ld\n", __FILE__, __LINE__, r, size); } - return r; + return malloc(size); } + void *toku_tagmalloc(size_t size, enum typ_tag typtag) { //printf("%s:%d tagmalloc\n", __FILE__, __LINE__); void *r = toku_malloc(size); @@ -178,32 +28,15 @@ void *toku_tagmalloc(size_t size, enum typ_tag typtag) { } void *toku_realloc(void *p, size_t size) { - if (p==0) return toku_malloc(size); - void *newp; - note_did_free(p); - errno=0; - newp = actual_realloc(p, size); - note_did_malloc(newp, size); - //printf("%s:%d realloc(%p,%ld)-->%p (%lld)\n", __FILE__, __LINE__, p, size, newp, n_items_malloced); - return newp; + return realloc(p, size); } void toku_free(void* p) { - //printf("%s:%d free(%p) (%lld)\n", __FILE__, __LINE__, p, n_items_malloced-1); - note_did_free(p); - actual_free(p); + free(p); } -void toku_free_n(void* p, size_t size) { - //printf("%s:%d free(%p) (%lld)\n", __FILE__, __LINE__, p, n_items_malloced-1); - note_did_free(p); - if (size>=sizeof(void*) && size0) { - fprintf(stderr, "n_items_malloced=%lld\n", n_items_malloced); - if (toku_memory_check) { - int i; - for (i=0; i