2007-11-29 14:18:54 +00:00
|
|
|
/* -*- mode: C; c-basic-offset: 4 -*- */
|
2008-01-24 15:10:32 +00:00
|
|
|
#ident "Copyright (c) 2007, 2008 Tokutek Inc. All rights reserved."
|
2007-11-29 14:18:54 +00:00
|
|
|
|
2013-04-16 23:57:22 -04:00
|
|
|
#include "portability.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "toku_assert.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <errno.h>
|
2007-07-13 19:37:47 +00:00
|
|
|
|
2007-11-29 15:34:49 +00:00
|
|
|
int toku_memory_check=0;
|
2007-07-13 19:37:47 +00:00
|
|
|
|
2008-01-23 18:35:54 +00:00
|
|
|
void *toku_calloc(size_t nmemb, size_t size) {
|
2008-07-17 20:58:57 +00:00
|
|
|
return calloc(nmemb, size);
|
2007-07-13 19:37:47 +00:00
|
|
|
}
|
2007-08-07 23:38:05 +00:00
|
|
|
|
2008-01-24 20:31:16 +00:00
|
|
|
void *toku_malloc(size_t size) {
|
2008-07-17 20:58:57 +00:00
|
|
|
return malloc(size);
|
2007-07-13 19:37:47 +00:00
|
|
|
}
|
2008-07-17 20:58:57 +00:00
|
|
|
|
2013-04-16 23:57:18 -04:00
|
|
|
void *toku_xmalloc(size_t size) {
|
|
|
|
void *r = malloc(size);
|
|
|
|
if (r==0) abort();
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2008-04-02 23:40:36 +00:00
|
|
|
void *toku_tagmalloc(size_t size, enum typ_tag typtag) {
|
2007-07-23 15:11:54 +00:00
|
|
|
//printf("%s:%d tagmalloc\n", __FILE__, __LINE__);
|
2007-07-20 18:00:14 +00:00
|
|
|
void *r = toku_malloc(size);
|
2008-04-02 23:40:36 +00:00
|
|
|
if (!r) return 0;
|
2007-07-13 19:37:47 +00:00
|
|
|
assert(size>sizeof(int));
|
|
|
|
((int*)r)[0] = typtag;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2008-01-23 18:35:54 +00:00
|
|
|
void *toku_realloc(void *p, size_t size) {
|
2008-07-17 20:58:57 +00:00
|
|
|
return realloc(p, size);
|
2007-07-13 19:37:47 +00:00
|
|
|
}
|
|
|
|
|
2007-07-20 18:00:14 +00:00
|
|
|
void toku_free(void* p) {
|
2008-07-17 20:58:57 +00:00
|
|
|
free(p);
|
2007-07-13 19:37:47 +00:00
|
|
|
}
|
|
|
|
|
2008-07-17 20:58:57 +00:00
|
|
|
void toku_free_n(void* p, size_t size __attribute__((unused))) {
|
|
|
|
free(p);
|
2007-08-07 23:38:05 +00:00
|
|
|
}
|
|
|
|
|
2008-01-23 18:35:54 +00:00
|
|
|
void *toku_memdup (const void *v, size_t len) {
|
2007-07-20 18:00:14 +00:00
|
|
|
void *r=toku_malloc(len);
|
2007-07-13 19:37:47 +00:00
|
|
|
memcpy(r,v,len);
|
|
|
|
return r;
|
|
|
|
}
|
2008-07-11 22:00:06 +00:00
|
|
|
|
2007-08-01 02:37:21 +00:00
|
|
|
char *toku_strdup (const char *s) {
|
2007-11-29 15:41:46 +00:00
|
|
|
return toku_memdup(s, strlen(s)+1);
|
2007-07-13 19:37:47 +00:00
|
|
|
}
|
|
|
|
|
2007-11-29 15:34:49 +00:00
|
|
|
void toku_memory_check_all_free (void) {
|
2007-07-13 19:37:47 +00:00
|
|
|
}
|
|
|
|
|
2008-07-17 20:58:57 +00:00
|
|
|
int toku_get_n_items_malloced (void) { return 0; }
|
2007-11-29 15:34:49 +00:00
|
|
|
void toku_print_malloced_items (void) {
|
2007-07-13 19:37:47 +00:00
|
|
|
}
|
2007-08-07 23:14:09 +00:00
|
|
|
|
2007-11-29 15:41:46 +00:00
|
|
|
void toku_malloc_report (void) {
|
2007-08-07 23:14:09 +00:00
|
|
|
}
|
2007-08-07 23:38:05 +00:00
|
|
|
|
2007-11-29 15:34:49 +00:00
|
|
|
void toku_malloc_cleanup (void) {
|
2007-08-07 23:38:05 +00:00
|
|
|
}
|