Commit 7cc6e1fb authored by Yoni Fogel's avatar Yoni Fogel

Manual glue for svn-git migration for r8452 due to multiple merge + diffs in the same patch.

Original message:
Create a branch to make Doug Lea's malloc work. The big problem is having another malloc() in the system breaks things. Address #1343, #1032.
parent bebdb218
......@@ -21,7 +21,7 @@ utils.dir: src.dir
build: $(patsubst %,%.dir, $(BUILDDIRS));
CHECKS = $(patsubst %,%.checkdir,$(SRCDIRS))
CHECKS = $(patsubst %,%.checkdir,$(filter-out linux, $(SRCDIRS)))
# This is the original check rule
# The stuff below allows "make -j2 -k check" to work
......
......@@ -91,7 +91,7 @@ COMBINE_C = -combine -c
LIBPORTABILITY = $(TOKUROOT)lib/libtokuportability.$(AEXT)
PORTABILITY_HEADERS= $(TOKUROOT)linux
ALWAYS_LINK= $(LIBPORTABILITY) -lz -lpthread
ALWAYS_LINK= -lz -lpthread
C99 = -std=c99
W64 = #-Wshorten-64-to-32
BINOUTPUT = -o
......@@ -128,7 +128,6 @@ LINK_DLINK_FILES=$(patsubst %,$(LINK)%,$(notdir $(DLINK_FILES_PREPROCESS_2)))
CRUNTIME=
DEPEND_LINK += \
$(LIBPORTABILITY) \
$(LINK_FILES) \
# keep this line so I can have a \ on the previous line
......@@ -185,7 +184,7 @@ ifneq ($(CYGWIN),)
#Cygwin (Windows) Must override some settings
BINSUF=.exe
WRONGBINSUF=#empty
ALWAYS_LINK=$(LIBPORTABILITY) /usr/lib/libz.a
ALWAYS_LINK=/usr/lib/libz.a
VGRIND =#No Valgrind in cygwin
HGRIND =#No Hgrind in cygwin
FPICFLAGS=#FPIC is default and not allowed as an option.
......@@ -200,7 +199,7 @@ ifneq ($(CYGWIN),)
CRUNTIME=MDd
endif
endif
ALWAYS_LINK=$(LIBPORTABILITY) $(TOKUROOT)windows/lib/$(CRUNTIME)/zlib.lib Ws2_32.lib psapi.lib
ALWAYS_LINK=$(TOKUROOT)windows/lib/$(CRUNTIME)/zlib.lib Ws2_32.lib psapi.lib
LINK=#Empty
BINOUTPUT=-Fe
OOUTPUT=-Fo
......
......@@ -20,8 +20,8 @@ enum typ_tag { TYP_BRTNODE = 0xdead0001,
};
/* Everything should call toku_malloc() instead of malloc(), and toku_calloc() instead of calloc() */
void *toku_calloc(size_t nmemb, size_t size);
void *toku_malloc(size_t size);
void *toku_calloc(size_t nmemb, size_t size) __attribute__((__visibility__("default")));
void *toku_malloc(size_t size) __attribute__((__visibility__("default")));
// xmalloc aborts instead of return NULL if we run out of memory
void *toku_xmalloc(size_t size);
......@@ -31,10 +31,10 @@ void *toku_xmalloc(size_t size);
* really a (struct foo *), and you want to figure out what it is.
*/
void *toku_tagmalloc(size_t size, enum typ_tag typ);
void toku_free(void*);
void toku_free(void*) __attribute__((__visibility__("default")));
/* toku_free_n() should be used if the caller knows the size of the malloc'd object. */
void toku_free_n(void*, size_t size);
void *toku_realloc(void *, size_t size);
void *toku_realloc(void *, size_t size) __attribute__((__visibility__("default")));
/* MALLOC is a macro that helps avoid a common error:
* Suppose I write
......
......@@ -40,7 +40,7 @@ int toku_os_lock_file(char *name);
//Unlocks and closes a file locked by toku_os_lock_on_file
int toku_os_unlock_file(int fildes);
int toku_os_mkdir(const char *pathname, mode_t mode);
int toku_os_mkdir(const char *pathname, mode_t mode) __attribute__((__visibility__("default")));
// Get the current process user and kernel use times
int toku_os_get_process_times(struct timeval *usertime, struct timeval *kerneltime);
......@@ -51,7 +51,7 @@ int toku_os_get_rss(int64_t *rss);
// Get the maximum in memory size (in bytes) of the current process
int toku_os_get_max_rss(int64_t *maxrss);
int toku_os_initialize_settings(int verbosity);
int toku_os_initialize_settings(int verbosity) __attribute__((__visibility__("default")));
//
// this int acts like a bool, returns 0 for false, 1 for true
......
......@@ -72,13 +72,20 @@ extern "C" {
// Deprecated functions.
#if !defined(TOKU_ALLOW_DEPRECATED)
# if defined(__ICL) //Windows Intel Compiler
# pragma deprecated (fstat, getpid, syscall, sysconf, mkdir)
# pragma deprecated (fstat, getpid, syscall, sysconf, mkdir, strdup, malloc, free)
# else
int fstat() __attribute__((__deprecated__));
int getpid(void) __attribute__((__deprecated__));
long int syscall(long int __sysno, ...) __attribute__((__deprecated__));
long int sysconf(int) __attribute__((__deprecated__));
int mkdir() __attribute__((__deprecated__));
// strdup is a macro in some libraries.
#undef strdup
char* strdup(const char *) __attribute__((__deprecated__));
#undef __strdup
char* __strdup(const char *) __attribute__((__deprecated__));
void *malloc(size_t) __attribute__((__deprecated__));
void free(void*) __attribute__((__deprecated__));
# endif
#endif
......
This diff is collapsed.
This diff is collapsed.
......@@ -29,7 +29,6 @@ BINS_RAW= \
BINS_O = $(patsubst %,%.$(OEXT),$(BINS_RAW))
.PHONY: build default bins libs
build default: bins libs $(TEST_NEWBRT)
......@@ -101,6 +100,7 @@ bins: $(BINS)
check: bins
$(MAYBEATSIGN)cd tests;$(MAKE) check
%$(BINSUF): BIN_FROM_C_FLAGS+=$(LIBPORTABILITY)
%$(BINSUF): $(NEWBRT) $(LIBPORTABILITY)
checko2:
......
......@@ -294,4 +294,6 @@ int toku_brtheader_checkpoint (CACHEFILE cachefile, void *header_v);
// So 4096 should be enough.
#define BLOCK_ALLOCATOR_HEADER_RESERVE 4096
int toku_db_badformat(void);
#endif
......@@ -368,14 +368,14 @@ int toku_deserialize_brtnode_from (int fd, BLOCKNUM blocknum, u_int32_t fullhash
//printf("%s:%d r=%d the datasize=%d\n", __FILE__, __LINE__, r, toku_ntohl(datasize_n));
if (r!=(int)sizeof(uncompressed_header)) {
if (r==-1) r=errno;
else r = DB_BADFORMAT;
else r = toku_db_badformat();
goto died0;
}
compressed_size = toku_ntohl(*(u_int32_t*)(&uncompressed_header[uncompressed_magic_len]));
if (compressed_size<=0 || compressed_size>(1<<30)) { r = DB_BADFORMAT; goto died0; }
if (compressed_size<=0 || compressed_size>(1<<30)) { r = toku_db_badformat(); goto died0; }
uncompressed_size = toku_ntohl(*(u_int32_t*)(&uncompressed_header[uncompressed_magic_len+4]));
if (0) printf("Block %" PRId64 " Compressed size = %u, uncompressed size=%u\n", blocknum.b, compressed_size, uncompressed_size);
if (uncompressed_size<=0 || uncompressed_size>(1<<30)) { r = DB_BADFORMAT; goto died0; }
if (uncompressed_size<=0 || uncompressed_size>(1<<30)) { r = toku_db_badformat(); goto died0; }
}
//printf("%s:%d serializing %" PRIu64 " size=%d\n", __FILE__, __LINE__, blocknum.b, uncompressed_size);
......@@ -418,7 +418,7 @@ int toku_deserialize_brtnode_from (int fd, BLOCKNUM blocknum, u_int32_t fullhash
rbuf_literal_bytes(&rc, &tmp, 8);
if (memcmp(tmp, "tokuleaf", 8)!=0
&& memcmp(tmp, "tokunode", 8)!=0) {
r = DB_BADFORMAT;
r = toku_db_badformat();
return r;
}
}
......@@ -428,7 +428,7 @@ int toku_deserialize_brtnode_from (int fd, BLOCKNUM blocknum, u_int32_t fullhash
case BRT_LAYOUT_VERSION_9: goto ok_layout_version;
// Don't support older versions.
}
r=DB_BADFORMAT;
r=toku_db_badformat();
return r;
ok_layout_version: ;
}
......@@ -489,7 +489,7 @@ int toku_deserialize_brtnode_from (int fd, BLOCKNUM blocknum, u_int32_t fullhash
int j;
if (0) { died_12: j=result->u.n.n_bytes_in_buffers; }
for (j=0; j<i; j++) toku_fifo_free(&BNC_BUFFER(result,j));
return DB_BADFORMAT;
return toku_db_badformat();
}
}
{
......@@ -521,11 +521,11 @@ int toku_deserialize_brtnode_from (int fd, BLOCKNUM blocknum, u_int32_t fullhash
}
if (check_local_fingerprint != result->local_fingerprint) {
fprintf(stderr, "%s:%d local fingerprint is wrong (found %8x calcualted %8x\n", __FILE__, __LINE__, result->local_fingerprint, check_local_fingerprint);
return DB_BADFORMAT;
return toku_db_badformat();
}
if (check_subtree_fingerprint+check_local_fingerprint != subtree_fingerprint) {
fprintf(stderr, "%s:%d subtree fingerprint is wrong\n", __FILE__, __LINE__);
return DB_BADFORMAT;
return toku_db_badformat();
}
}
} else {
......@@ -555,7 +555,7 @@ int toku_deserialize_brtnode_from (int fd, BLOCKNUM blocknum, u_int32_t fullhash
toku_free(array);
if (r!=0) {
if (0) { died_21: toku_omt_destroy(&result->u.l.buffer); }
return DB_BADFORMAT;
return toku_db_badformat();
}
result->u.l.buffer_mempool.frag_size = start_of_data;
......@@ -564,7 +564,7 @@ int toku_deserialize_brtnode_from (int fd, BLOCKNUM blocknum, u_int32_t fullhash
if (r!=0) goto died_21;
if (actual_sum!=result->local_fingerprint) {
//fprintf(stderr, "%s:%d Corrupted checksum stored=%08x rand=%08x actual=%08x height=%d n_keys=%d\n", __FILE__, __LINE__, result->rand4fingerprint, result->local_fingerprint, actual_sum, result->height, n_in_buf);
return DB_BADFORMAT;
return toku_db_badformat();
// goto died_21;
} else {
//fprintf(stderr, "%s:%d Good checksum=%08x height=%d\n", __FILE__, __LINE__, actual_sum, result->height);
......@@ -575,7 +575,7 @@ int toku_deserialize_brtnode_from (int fd, BLOCKNUM blocknum, u_int32_t fullhash
{
unsigned int n_read_so_far = rc.ndone;
if (n_read_so_far+4!=rc.size) {
r = DB_BADFORMAT; goto died_21;
r = toku_db_badformat(); goto died_21;
}
uint32_t crc = x1764_memory(rc.buf, n_read_so_far);
uint32_t storedcrc = rbuf_int(&rc);
......@@ -583,7 +583,7 @@ int toku_deserialize_brtnode_from (int fd, BLOCKNUM blocknum, u_int32_t fullhash
printf("Bad CRC\n");
printf("%s:%d crc=%08x stored=%08x\n", __FILE__, __LINE__, crc, storedcrc);
assert(0);//this is wrong!!!
r = DB_BADFORMAT;
r = toku_db_badformat();
goto died_21;
}
}
......@@ -808,10 +808,10 @@ deserialize_brtheader (u_int32_t size, int fd, DISKOFF off, struct brt_header **
if (h->n_named_roots>=0) {
int i;
int n_to_malloc = (h->n_named_roots == 0) ? 1 : h->n_named_roots;
MALLOC_N(n_to_malloc, h->flags_array); if (h->flags_array==0) { ret=errno; if (0) { died2: free(h->flags_array); } goto died1; }
MALLOC_N(n_to_malloc, h->roots); if (h->roots==0) { ret=errno; if (0) { died3: if (h->n_named_roots>=0) free(h->roots); } goto died2; }
MALLOC_N(n_to_malloc, h->root_hashes); if (h->root_hashes==0) { ret=errno; if (0) { died4: if (h->n_named_roots>=0) free(h->root_hashes); } goto died3; }
MALLOC_N(n_to_malloc, h->names); if (h->names==0) { ret=errno; if (0) { died5: if (h->n_named_roots>=0) free(h->names); } goto died4; }
MALLOC_N(n_to_malloc, h->flags_array); if (h->flags_array==0) { ret=errno; if (0) { died2: toku_free(h->flags_array); } goto died1; }
MALLOC_N(n_to_malloc, h->roots); if (h->roots==0) { ret=errno; if (0) { died3: if (h->n_named_roots>=0) toku_free(h->roots); } goto died2; }
MALLOC_N(n_to_malloc, h->root_hashes); if (h->root_hashes==0) { ret=errno; if (0) { died4: if (h->n_named_roots>=0) toku_free(h->root_hashes); } goto died3; }
MALLOC_N(n_to_malloc, h->names); if (h->names==0) { ret=errno; if (0) { died5: if (h->n_named_roots>=0) toku_free(h->names); } goto died4; }
for (i=0; i<h->n_named_roots; i++) {
h->root_hashes[i].valid = FALSE;
h->roots[i] = rbuf_blocknum(&rc);
......@@ -997,3 +997,7 @@ static int deserialize_fifo_at (int fd, toku_off_t at, FIFO *fifo) {
//printf("%s:%d *fifo=%p\n", __FILE__, __LINE__, result);
return 0;
}
int toku_db_badformat(void) {
return DB_BADFORMAT;
}
......@@ -200,14 +200,14 @@ dump_fragmentation(int f, struct brt_header *h) {
toku_brtnode_free(&n);
}
size_t n = h->translated_blocknum_limit * sizeof (struct block_translation_pair);
struct block_translation_pair *bx = malloc(n);
struct block_translation_pair *bx = toku_malloc(n);
memcpy(bx, h->block_translation, n);
qsort(bx, h->translated_blocknum_limit, sizeof (struct block_translation_pair), bxpcmp);
for (i = 0; i < h->translated_blocknum_limit - 1; i++) {
// printf("%lu %lu %lu\n", i, bx[i].diskoff, bx[i].size);
fragsizes += bx[i+1].diskoff - (bx[i].diskoff + bx[i].size);
}
free(bx);
toku_free(bx);
printf("translated_blocknum_limit: %" PRIu64 "\n", h->translated_blocknum_limit);
printf("leafblocks: %" PRIu64 "\n", leafblocks);
printf("blocksizes: %" PRIu64 "\n", blocksizes);
......
......@@ -724,6 +724,7 @@ int toku_cachetable_get_and_pin(CACHEFILE cachefile, CACHEKEY key, u_int32_t ful
LSN written_lsn;
WHEN_TRACE_CT(printf("%s:%d CT: fetch_callback(%lld...)\n", __FILE__, __LINE__, key));
if ((r=fetch_callback(cachefile, key, fullhash, &toku_value, &size, extraargs, &written_lsn))) {
if (r == DB_BADFORMAT) toku_db_badformat();
cachetable_unlock(t);
return r;
}
......@@ -733,6 +734,7 @@ int toku_cachetable_get_and_pin(CACHEFILE cachefile, CACHEKEY key, u_int32_t ful
*sizep = size;
}
r = maybe_flush_some(t, 0);
if (r == DB_BADFORMAT) toku_db_badformat();
cachetable_unlock(t);
WHEN_TRACE_CT(printf("%s:%d did fetch: cachtable_get_and_pin(%lld)--> %p\n", __FILE__, __LINE__, key, *value));
return r;
......
......@@ -63,7 +63,7 @@ int toku_logger_find_logfiles (const char *directory, char ***resultp) {
struct dirent *de;
DIR *d=opendir(directory);
if (d==0) {
free(result);
toku_free(result);
return errno;
}
int dirnamelen = strlen(directory);
......@@ -974,9 +974,9 @@ int toku_logger_log_archive (TOKULOGGER logger, char ***logs_p, int flags) {
result[n_to_archive]=0;
}
for (i=0; all_logs[i]; i++) {
free(all_logs[i]);
toku_free(all_logs[i]);
}
free(all_logs);
toku_free(all_logs);
*logs_p = result;
return 0;
}
......
......@@ -37,7 +37,7 @@ int toku_rollback_fcreate (TXNID xid __attribute__((__unused__)),
}
r = unlink(full_fname);
assert(r==0);
free(fname);
toku_free(fname);
return 0;
}
......@@ -175,7 +175,7 @@ int toku_commit_rollinclude (BYTESTRING bs,TOKUTXN txn) {
r = close(fd);
assert(r==0);
unlink(fname);
free(fname);
toku_free(fname);
return 0;
}
......@@ -192,6 +192,6 @@ int toku_rollback_rollinclude (BYTESTRING bs,TOKUTXN txn) {
r = close(fd);
assert(r==0);
unlink(fname);
free(fname);
toku_free(fname);
return 0;
}
......@@ -85,6 +85,8 @@ BINS_RAW = $(REGRESSION_TESTS_RAW) \
# This line intentially kept commented so I can have a \ on the end of the previous line
# BINS will be defined by adding .exe if appropriate.
$(BINS): BIN_FROM_C_FLAGS+=$(LIBPORTABILITY)
CHECKS = \
benchmarktest_256 \
test-assertA \
......
......@@ -13,14 +13,14 @@ flush (CACHEFILE cf __attribute__((__unused__)),
BOOL rename_p __attribute__((__unused__))
) {
assert((long) key.b == size);
if (!keep_me) free(v);
if (!keep_me) toku_free(v);
}
static int
fetch (CACHEFILE cf, CACHEKEY key, u_int32_t hash, void **vptr, long *sizep, void *extra, LSN *written_lsn) {
cf = cf; hash = hash; extra = extra; written_lsn = written_lsn;
*sizep = (long) key.b;
*vptr = malloc(*sizep);
*vptr = toku_malloc(*sizep);
return 0;
}
......
......@@ -26,7 +26,7 @@ static void f_flush (CACHEFILE f,
assert(r==BLOCKSIZE);
}
if (!keep_me) {
free(value);
toku_free(value);
}
}
......@@ -37,7 +37,7 @@ static int f_fetch (CACHEFILE f,
long *sizep,
void*extraargs __attribute__((__unused__)),
LSN *modified_lsn __attribute__((__unused__))) {
void *buf = malloc(BLOCKSIZE);
void *buf = toku_malloc(BLOCKSIZE);
int r = pread(toku_cachefile_fd(f), buf, BLOCKSIZE, key.b);
assert(r==BLOCKSIZE);
*value = buf;
......@@ -61,7 +61,7 @@ static void writeit (void) {
gettimeofday(&start, 0);
int i, r;
for (i=0; i<N; i++) {
void *buf = malloc(BLOCKSIZE);
void *buf = toku_malloc(BLOCKSIZE);
CACHEKEY key = make_blocknum(i*BLOCKSIZE);
u_int32_t fullhash = toku_cachetable_hash(f, key);
int j;
......
......@@ -11,13 +11,13 @@ struct ctpair {
static PAIR
new_pair (void) {
PAIR p = (PAIR) malloc(sizeof *p); assert(p);
PAIR p = (PAIR) toku_malloc(sizeof *p); assert(p);
return p;
}
static void
destroy_pair(PAIR p) {
free(p);
toku_free(p);
}
#include "cachetable-writequeue.h"
......
......@@ -62,8 +62,8 @@ test_fifo_enq (int n) {
});
assert(i == n);
if (thekey) free(thekey);
if (theval) free(theval);
if (thekey) toku_free(thekey);
if (theval) toku_free(theval);
while (toku_fifo_deq(f) == 0)
;
......
......@@ -21,7 +21,7 @@ static void test_push_pop (int n) {
list_init(&head);
for (i=0; i<n; i++) {
struct testlist *tl = (struct testlist *) malloc(sizeof *tl);
struct testlist *tl = (struct testlist *) toku_malloc(sizeof *tl);
assert(tl);
testlist_init(tl, i);
list_push(&head, &tl->next);
......@@ -40,7 +40,7 @@ static void test_push_pop (int n) {
list = list_pop(&head);
tl = list_struct(list, struct testlist, next);
assert(tl->tag == i);
free(tl);
toku_free(tl);
}
assert(list_empty(&head));
}
......@@ -51,7 +51,7 @@ static void test_push_pop_head (int n) {
list_init(&head);
for (i=0; i<n; i++) {
struct testlist *tl = (struct testlist *) malloc(sizeof *tl);
struct testlist *tl = (struct testlist *) toku_malloc(sizeof *tl);
assert(tl);
testlist_init(tl, i);
list_push(&head, &tl->next);
......@@ -71,7 +71,7 @@ static void test_push_pop_head (int n) {
list = list_pop_head(&head);
tl = list_struct(list, struct testlist, next);
assert(tl->tag == i);
free(tl);
toku_free(tl);
}
assert(list_empty(&head));
}
......@@ -82,7 +82,7 @@ static void test_push_head_pop (int n) {
list_init(&head);
for (i=0; i<n; i++) {
struct testlist *tl = (struct testlist *) malloc(sizeof *tl);
struct testlist *tl = (struct testlist *) toku_malloc(sizeof *tl);
assert(tl);
testlist_init(tl, i);
list_push_head(&head, &tl->next);
......@@ -102,7 +102,7 @@ static void test_push_head_pop (int n) {
list = list_pop(&head);
tl = list_struct(list, struct testlist, next);
assert(tl->tag == i);
free(tl);
toku_free(tl);
}
assert(list_empty(&head));
}
......@@ -127,7 +127,7 @@ static void test_move (int n) {
list_init(&h1);
list_init(&h2);
for (i=0; i<n; i++) {
struct testlist *tl = (struct testlist *) malloc(sizeof *tl);
struct testlist *tl = (struct testlist *) toku_malloc(sizeof *tl);
assert(tl);
testlist_init(tl, i);
list_push(&h2, &tl->next);
......@@ -140,7 +140,7 @@ static void test_move (int n) {
struct list *list = list_pop_head(&h1);
struct testlist *tl = list_struct(list, struct testlist, next);
assert(tl->tag == i);
free(tl);
toku_free(tl);
i += 1;
}
assert(i == n);
......
......@@ -11,7 +11,7 @@
static void
test_mempool_limits (size_t size) {
void *base = malloc(size);
void *base = toku_malloc(size);
struct mempool mempool;
toku_mempool_init(&mempool, base, size);
......@@ -24,12 +24,12 @@ test_mempool_limits (size_t size) {
assert(i == size);
toku_mempool_fini(&mempool);
free(base);
toku_free(base);
}
static void
test_mempool_malloc_mfree (size_t size) {
void *base = malloc(size);
void *base = toku_malloc(size);
struct mempool mempool;
toku_mempool_init(&mempool, base, size);
......@@ -49,7 +49,7 @@ test_mempool_malloc_mfree (size_t size) {
assert(toku_mempool_get_frag_size(&mempool) == size);
toku_mempool_fini(&mempool);
free(base);
toku_free(base);
}
int
......
......@@ -22,7 +22,7 @@ doit (void) {
int r;
fnamelen = strlen(__FILE__) + 20;
fname = malloc(fnamelen);
fname = toku_malloc(fnamelen);
assert(fname!=0);
snprintf(fname, fnamelen, "%s.brt", __FILE__);
......@@ -30,7 +30,7 @@ doit (void) {
unlink(fname);
r = toku_open_brt(fname, 0, 1, &t, NODESIZE, ct, null_txn, toku_default_compare_fun, null_db);
assert(r==0);
free(fname);
toku_free(fname);
r = toku_testsetup_leaf(t, &nodea);
assert(r==0);
......
......@@ -51,7 +51,7 @@ doit (int ksize __attribute__((__unused__))) {
int r;
fnamelen = strlen(__FILE__) + 20;
fname = malloc(fnamelen);
fname = toku_malloc(fnamelen);
assert(fname!=0);
snprintf(fname, fnamelen, "%s.brt", __FILE__);
......@@ -77,7 +77,7 @@ doit (int ksize __attribute__((__unused__))) {
for (i=0; i+1<BRT_FANOUT; i++) {
char key[TOKU_PSIZE];
keylens[i]=1+snprintf(key, TOKU_PSIZE, "%08d", (i+1)*10000);
keys[i]=strdup(key);
keys[i]=toku_strdup(key);
}
r = toku_testsetup_nonleaf(t, 1, &bnode, BRT_FANOUT, cnodes, fingerprints, keys, keylens);
......
......@@ -8,6 +8,6 @@ test_main (int argc, const char *argv[]) {
default_parse_args(argc, argv);
char *m=toku_malloc(5);
m=m;
free(m);
toku_free(m);
return 0;
}
......@@ -12,7 +12,7 @@ struct threadpool {
int threadpool_create(THREADPOOL *threadpoolptr, int max_threads) {
size_t size = sizeof (struct threadpool) + max_threads*sizeof (toku_pthread_t);
struct threadpool *threadpool = malloc(size);
struct threadpool *threadpool = toku_malloc(size);
if (threadpool == 0)
return ENOMEM;
threadpool->max_threads = max_threads;
......@@ -34,7 +34,7 @@ void threadpool_destroy(THREADPOOL *threadpoolptr) {
assert(r == 0);
}
*threadpoolptr = 0;
free(threadpool);
toku_free(threadpool);
}
void threadpool_maybe_add(THREADPOOL threadpool, void *(*f)(void *), void *arg) {
......
......@@ -16,6 +16,10 @@
toku_add_trace_mem;
toku_print_trace_mem;
toku_os_mkdir;
toku_free;
toku_os_initialize_settings;
local: *;
};
......@@ -158,7 +158,8 @@ endif
%.bdb$(BINSUF): CFLAGS+= -DENVDIR=\"dir.$<.bdb\" -DUSE_BDB -DIS_TDB=0
%.bdb$(BINSUF): %.c $(DEPEND_COMPILE) $(DEPEND_LINK)
$(MAYBEATSIGN)$(CC) $< $(BIN_FROM_C_FLAGS)
echo portability now $(LIBPORTABILITY)
$(MAYBEATSIGN)$(CC) $< $(BIN_FROM_C_FLAGS) $(LIBPORTABILITY)
%.tdb$(BINSUF): DLINK_FILES+=$(LIBTDB)
%.tdb$(BINSUF): RPATH_DIRS+=$(dir $(LIBTDB))
......
......@@ -2,6 +2,7 @@
#include "test.h"
#include <sys/stat.h>
#include <memory.h>
static void
do_627 (void) {
......@@ -32,10 +33,10 @@ do_627 (void) {
r=db->cursor(db, t2, &c2, 0); CKERR(r);
r=c1->c_get(c1, dbt_init(&a, "a", 2), dbt_init_malloc(&b), DB_SET); CKERR(r);
free(b.data);
toku_free(b.data);
r=c2->c_get(c2, dbt_init(&a, "a", 2), dbt_init_malloc(&b), DB_SET); CKERR(r);
free(b.data);
toku_free(b.data);
// This causes all hell to break loose in BDB 4.6, so we just cannot run this under BDB.
// PANIC: Invalid argument
......
......@@ -5,8 +5,10 @@
#include <pthread.h>
#include <sys/stat.h>
#include <unistd.h>
#include <memory.h>
#include "test.h"
DB_ENV *env;
DB *db;
......@@ -65,7 +67,7 @@ void *starta(void* ignore __attribute__((__unused__))) {
assert(r==0);
//printf("val.data=%p\n", val.data);
int i; for (i=0; i<10; i++) assert(((char*)val.data)[i]==0);
free(val.data);
toku_free(val.data);
return 0;
}
void *startb(void* ignore __attribute__((__unused__))) {
......@@ -79,7 +81,7 @@ void *startb(void* ignore __attribute__((__unused__))) {
assert(r==0);
//printf("val.data=%p\n", val.data);
int i; for (i=0; i<10; i++) assert(((char*)val.data)[i]==0);
free(val.data);
toku_free(val.data);
return 0;
}
......
......@@ -5,6 +5,7 @@
#include <pthread.h>
#include <sys/stat.h>
#include <unistd.h>
#include <memory.h>
#include "test.h"
DB_ENV *env;
......@@ -79,7 +80,7 @@ void *startb(void* ignore __attribute__((__unused__))) {
assert(r==0);
//printf("val.data=%p\n", val.data);
int i; for (i=0; i<10; i++) assert(((char*)val.data)[i]==0);
free(val.data);
toku_free(val.data);
return 0;
}
......
......@@ -5,6 +5,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <memory.h>
#include "test.h"
......@@ -44,7 +45,7 @@ static void test (void) {
r=db->open(db, tid, "foo.db", 0, DB_BTREE, 0, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db->get(db, tid, dbt_init(&key, "a", 2), dbt_init_malloc(&data), 0); assert(r==0);
r=tid->commit(tid, 0); assert(r==0);
free(data.data);
toku_free(data.data);
r=db->close(db, 0); CKERR(r);
r=env->close(env, 0); CKERR(r);
}
......
......@@ -5,6 +5,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <memory.h>
#include "test.h"
......@@ -35,8 +36,8 @@ static void test (void) {
for (i=0; i<N; i++) {
char ks[100]; snprintf(ks, sizeof(ks), "k%09ld.%d", random(), i);
char vs[1000]; snprintf(vs, sizeof(vs), "v%d.%0*d", i, (int)(sizeof(vs)-100), i);
keys[i]=strdup(ks);
vals[i]=strdup(vs);
keys[i]=toku_strdup(ks);
vals[i]=toku_strdup(vs);
r=db->put(db, tid, dbt_init(&key, ks, strlen(ks)+1), dbt_init(&data, vs, strlen(vs)+1), 0); assert(r==0);
}
r=tid->commit(tid, 0); assert(r==0);
......@@ -55,13 +56,13 @@ static void test (void) {
for (i=0; i<N; i++) {
r=db->get(db, tid, dbt_init(&key, keys[i], 1+strlen(keys[i])), dbt_init_malloc(&data), 0); assert(r==0);
assert(strcmp(data.data, vals[i])==0);
free(data.data);
toku_free(data.data);
data.data=0;
free(keys[i]);
free(vals[i]);
toku_free(keys[i]);
toku_free(vals[i]);
}
r=tid->commit(tid, 0); assert(r==0);
free(data.data);
toku_free(data.data);
r=db->close(db, 0); CKERR(r);
r=env->close(env, 0); CKERR(r);
}
......
......@@ -10,6 +10,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
#include <memory.h>
#include "test.h"
......@@ -40,8 +41,8 @@ static void test (void) {
for (i=0; i<N; i++) {
char ks[100]; snprintf(ks, sizeof(ks), "k%09ld.%d", random(), i);
char vs[1000]; snprintf(vs, sizeof(vs), "v%d.%0*d", i, (int)(sizeof(vs)-100), i);
keys[i]=strdup(ks);
vals[i]=strdup(vs);
keys[i]=toku_strdup(ks);
vals[i]=toku_strdup(vs);
r=db->put(db, tid, dbt_init(&key, ks, strlen(ks)+1), dbt_init(&data, vs, strlen(vs)+1), 0); assert(r==0);
if (i%500==499) {
r=tid->commit(tid, 0); assert(r==0);
......@@ -64,17 +65,17 @@ static void test (void) {
for (i=0; i<N; i++) {
r=db->get(db, tid, dbt_init(&key, keys[i], 1+strlen(keys[i])), dbt_init_malloc(&data), 0); assert(r==0);
assert(strcmp(data.data, vals[i])==0);
free(data.data);
toku_free(data.data);
data.data=0;
free(keys[i]);
free(vals[i]);
toku_free(keys[i]);
toku_free(vals[i]);
if (i%500==499) {
r=tid->commit(tid, 0); assert(r==0);
r=env->txn_begin(env, 0, &tid, 0); assert(r==0);
}
}
r=tid->commit(tid, 0); assert(r==0);
free(data.data);
toku_free(data.data);
r=db->close(db, 0); CKERR(r);
r=env->close(env, 0); CKERR(r);
}
......
......@@ -3,10 +3,11 @@
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
#include <memory.h>
#include "test.h"
static void
......@@ -71,7 +72,7 @@ test_789(void) {
*(char*)val.data = 1;
r = db->put(db, txn, &key, &val, 0); assert(r == 0);
r = cursor->c_close(cursor); assert(r == 0);
free(key.data); free(val.data);
toku_free(key.data); toku_free(val.data);
r = txn->commit(txn, 0); assert(r == 0);
r = txn_master->abort(txn_master); assert(r == 0);
}
......@@ -88,7 +89,7 @@ test_789(void) {
r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); assert(r == 0);
r = cursor->c_del(cursor, 0); assert(r == 0);
r = cursor->c_close(cursor); assert(r == 0);
free(key.data); free(val.data);
toku_free(key.data); toku_free(val.data);
r = txn->commit(txn, 0); assert(r == 0);
r = txn_master->abort(txn_master); assert(r == 0);
}
......@@ -106,7 +107,7 @@ test_789(void) {
*(char*)val.data = 2;
r = db->put(db, txn, &key, &val, 0); assert(r == 0);
r = cursor->c_close(cursor); assert(r == 0);
free(key.data); free(val.data);
toku_free(key.data); toku_free(val.data);
r = txn->commit(txn, 0); assert(r == 0);
r = txn_master->commit(txn_master, 0); assert(r == 0);
}
......@@ -123,7 +124,7 @@ test_789(void) {
r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); assert(r == 0);
r = cursor->c_del(cursor, 0); assert(r == 0);
r = cursor->c_close(cursor); assert(r == 0);
free(key.data); free(val.data);
toku_free(key.data); toku_free(val.data);
r = txn->commit(txn, 0); assert(r == 0);
r = txn_master->commit(txn_master, 0); assert(r == 0);
}
......
......@@ -3,10 +3,11 @@
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
#include <memory.h>
#include "test.h"
static void
......@@ -40,7 +41,7 @@ testit (const int klen, const int vlen, const int n, const int lastvlen) {
// insert to fill up a node
{
void *v = malloc(vlen); assert(v); memset(v, 0, vlen);
void *v = toku_malloc(vlen); assert(v); memset(v, 0, vlen);
DB_TXN *txn = 0;
int i;
for (i=0; i<n; i++) {
......@@ -56,18 +57,18 @@ testit (const int klen, const int vlen, const int n, const int lastvlen) {
r = db->put(db, txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, v, lastvlen), 0);
assert(r == 0);
}
free(v);
toku_free(v);
}
// add another one to force a node split
{
void *v = malloc(vlen); assert(v); memset(v, 0, vlen);
void *v = toku_malloc(vlen); assert(v); memset(v, 0, vlen);
DB_TXN *txn = 0;
int k = htonl(n+1);
DBT key, val;
r = db->put(db, txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, v, vlen), 0);
assert(r == 0);
free(v);
toku_free(v);
}
// close db
......
......@@ -9,7 +9,7 @@
#include <sys/types.h>
#include <toku_portability.h>
#include <db.h>
#include <string.h>
#include <memory.h>
#include <stdio.h>
#include "test.h"
......
......@@ -2,6 +2,7 @@
#include <toku_portability.h>
#include <db.h>
#include <sys/stat.h>
#include <memory.h>
#include "test.h"
int
......@@ -47,7 +48,7 @@ test_main (int argc, const char *argv[]) {
assert(list);
assert(list[0]);
if (verbose) printf("file[0]=%s\n", list[0]);
free(list);
toku_free(list);
}
r=db->close(db, 0); CKERR(r);
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <inttypes.h>
#include <sys/stat.h>
#include <toku_portability.h>
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <errno.h>
#include <sys/stat.h>
#include <toku_portability.h>
......
......@@ -7,7 +7,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <errno.h>
#include <sys/stat.h>
#include <toku_portability.h>
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <errno.h>
#include <sys/stat.h>
#include <toku_portability.h>
......
......@@ -5,10 +5,10 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <memory.h>
#include <db.h>
#include "test.h"
......@@ -61,7 +61,7 @@ test_cursor_current (void) {
assert(data.size == sizeof vv);
memcpy(&vv, data.data, data.size);
assert(vv == v);
free(key.data); free(data.data);
toku_free(key.data); toku_free(data.data);
r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&data), DB_CURRENT);
assert(r == 0);
......@@ -71,7 +71,7 @@ test_cursor_current (void) {
assert(data.size == sizeof vv);
memcpy(&vv, data.data, data.size);
assert(vv == v);
free(key.data); free(data.data);
toku_free(key.data); toku_free(data.data);
r = cursor->c_del(cursor, 0);
assert(r == 0);
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <errno.h>
#include <sys/stat.h>
#include <toku_portability.h>
......@@ -28,8 +28,8 @@ cursor_expect (DBC *cursor, int k, int v, int op) {
assert(kk == k);
assert(vv == v);
free(key.data);
free(val.data);
toku_free(key.data);
toku_free(val.data);
}
static void
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <errno.h>
#include <sys/stat.h>
#include <toku_portability.h>
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <errno.h>
#include <sys/stat.h>
#include <toku_portability.h>
......@@ -47,8 +47,8 @@ test_cursor_delete2 (void) {
r = db->cursor(db, txn, &cursor, 0); CKERR(r);
r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_FIRST); CKERR(r);
assert(strcmp(key.data, "a")==0); free(key.data);
assert(strcmp(val.data, "c")==0); free(val.data);
assert(strcmp(key.data, "a")==0); toku_free(key.data);
assert(strcmp(val.data, "c")==0); toku_free(val.data);
r = cursor->c_del(cursor, 0); CKERR(r);
r = cursor->c_del(cursor, 0); assert(r==DB_KEYEMPTY);
r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_NEXT); assert(r==DB_NOTFOUND);
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
#include <string.h>
#include <memory.h>
#include <toku_portability.h>
#include <db.h>
#include <assert.h>
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <errno.h>
#include <sys/stat.h>
#include <toku_portability.h>
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......@@ -18,8 +18,8 @@ expect_cursor_get (DBC *cursor, int k, int v, int op) {
DBT key, val;
int r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), op);
assert(r == 0);
assert(key.size == sizeof kk); memcpy(&kk, key.data, key.size); assert(kk == k); free(key.data);
assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v); free(val.data);
assert(key.size == sizeof kk); memcpy(&kk, key.data, key.size); assert(kk == k); toku_free(key.data);
assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v); toku_free(val.data);
}
static DBC *
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
#include <string.h>
#include <memory.h>
#include <toku_portability.h>
#include <db.h>
#include <assert.h>
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......@@ -29,8 +29,8 @@ cursor_get (DBC *cursor, unsigned int *k, unsigned int *v, int op) {
assert(key.size == sizeof *k); memcpy(k, key.data, key.size);
assert(val.size == sizeof *v); memcpy(v, val.data, val.size);
}
if (key.data) free(key.data);
if (val.data) free(val.data);
if (key.data) toku_free(key.data);
if (val.data) toku_free(val.data);
return r;
}
......
/* Primary with two associated things. */
#include <assert.h>
#include <toku_portability.h>
#include <db.h>
#include <errno.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <memory.h>
#include <toku_portability.h>
#include "test.h"
......@@ -41,8 +41,8 @@ struct primary_data {
static void
free_pd (struct primary_data *pd) {
free(pd->name.name);
free(pd);
toku_free(pd->name.name);
toku_free(pd);
}
static void
......@@ -117,7 +117,7 @@ read_name_from_dbt (const DBT *dbt, unsigned int *off, struct name_key *nk) {
read_uchar_from_dbt(dbt, off, &buf[i]);
if (buf[i]==0) break;
}
nk->name=(unsigned char*)(strdup((char*)buf));
nk->name=(unsigned char*)(toku_strdup((char*)buf));
}
static void
......@@ -134,7 +134,7 @@ name_offset_in_pd_dbt (void) {
static int
name_callback (DB *UU(secondary), const DBT * UU(key), const DBT *data, DBT *result) {
struct primary_data *pd = malloc(sizeof(*pd));
struct primary_data *pd = toku_malloc(sizeof(*pd));
unsigned int off=0;
read_pd_from_dbt(data, &off, pd);
static int buf[1000];
......@@ -241,8 +241,8 @@ close_databases (void) {
if (name_cursor) {
r = name_cursor->c_close(name_cursor); CKERR(r);
}
if (nc_key.data) free(nc_key.data);
if (nc_data.data) free(nc_data.data);
if (nc_key.data) toku_free(nc_key.data);
if (nc_data.data) toku_free(nc_data.data);
r = namedb->close(namedb, 0); CKERR(r);
r = dbp->close(dbp, 0); CKERR(r);
r = expiredb->close(expiredb, 0); CKERR(r);
......@@ -417,7 +417,7 @@ delete_oldest_expired (void) {
count_all_items--;
}
savepkey = pkey;
savepkey.data = malloc(pkey.size);
savepkey.data = toku_malloc(pkey.size);
memcpy(savepkey.data, pkey.data, pkey.size);
switch (r3) {
case 0:
......@@ -438,7 +438,7 @@ delete_oldest_expired (void) {
assert(r==DB_KEYEMPTY);
r = dbp->get(dbp, null_txn, &savepkey, &data, 0);
assert(r==DB_NOTFOUND);
free(savepkey.data);
toku_free(savepkey.data);
}
// Use a cursor to step through the names.
......@@ -525,10 +525,10 @@ test_main (int argc, const char *argv[]) {
memset(&nc_key, 0, sizeof(nc_key));
memset(&nc_data, 0, sizeof(nc_data));
nc_key.flags = DB_DBT_REALLOC;
nc_key.data = malloc(1); // Iniitalize it.
nc_key.data = toku_malloc(1); // Iniitalize it.
((char*)nc_key.data)[0]=0;
nc_data.flags = DB_DBT_REALLOC;
nc_data.data = malloc(1); // Iniitalize it.
nc_data.data = toku_malloc(1); // Iniitalize it.
mode = MODE_DEFAULT;
......
......@@ -4,7 +4,7 @@
#include <toku_portability.h>
#include <db.h>
#include <errno.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <unistd.h>
#include <ctype.h>
......@@ -67,8 +67,8 @@ struct primary_data {
static void
free_pd (struct primary_data *pd) {
free(pd->name.name);
free(pd);
toku_free(pd->name.name);
toku_free(pd);
}
static void
......@@ -144,7 +144,7 @@ read_name_from_dbt (const DBT *dbt, unsigned int *off, struct name_key *nk) {
read_uchar_from_dbt(dbt, off, &buf[i]);
if (buf[i]==0) break;
}
nk->name=(unsigned char*)(strdup((char*)buf));
nk->name=(unsigned char*)(toku_strdup((char*)buf));
}
static void
......@@ -157,7 +157,7 @@ read_pd_from_dbt (const DBT *dbt, unsigned int *off, struct primary_data *pd) {
static int
name_callback (DB *secondary __attribute__((__unused__)), const DBT * UU(key), const DBT *data, DBT *result) {
struct primary_data *pd = malloc(sizeof(*pd));
struct primary_data *pd = toku_malloc(sizeof(*pd));
unsigned int off=0;
read_pd_from_dbt(data, &off, pd);
static int buf[1000];
......@@ -228,8 +228,8 @@ close_databases (void) {
if (name_cursor) {
r = name_cursor->c_close(name_cursor); CKERR(r);
}
if (nc_key.data) free(nc_key.data);
if (nc_data.data) free(nc_data.data);
if (nc_key.data) toku_free(nc_key.data);
if (nc_data.data) toku_free(nc_data.data);
r = namedb->close(namedb, 0); CKERR(r);
r = dbp->close(dbp, 0); CKERR(r);
r = expiredb->close(expiredb, 0); CKERR(r);
......@@ -412,7 +412,7 @@ delete_oldest_expired (void) {
}
count_all_items--;
DBT savepkey = pkey;
savepkey.data = malloc(pkey.size);
savepkey.data = toku_malloc(pkey.size);
memcpy(savepkey.data, pkey.data, pkey.size);
r = dbp->del(dbp, null_txn, &pkey, 0); CKERR(r);
// Make sure it's really gone.
......@@ -422,7 +422,7 @@ delete_oldest_expired (void) {
r = dbp->get(dbp, null_txn, &savepkey, &data, 0);
}
assert(r==DB_NOTFOUND);
free(savepkey.data);
toku_free(savepkey.data);
}
// Use a cursor to step through the names.
......@@ -495,10 +495,10 @@ test_main (int argc, const char *argv[]) {
memset(&nc_key, 0, sizeof(nc_key));
memset(&nc_data, 0, sizeof(nc_data));
nc_key.flags = DB_DBT_REALLOC;
nc_key.data = malloc(1); // Iniitalize it.
nc_key.data = toku_malloc(1); // Iniitalize it.
((char*)nc_key.data)[0]=0;
nc_data.flags = DB_DBT_REALLOC;
nc_data.data = malloc(1); // Iniitalize it.
nc_data.data = toku_malloc(1); // Iniitalize it.
mode = MODE_DEFAULT;
......
......@@ -4,7 +4,7 @@
#include <toku_portability.h>
#include <db.h>
#include <errno.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <unistd.h>
......@@ -36,8 +36,8 @@ struct primary_data {
};
static void free_pd (struct primary_data *pd) {
free(pd->name.name);
free(pd);
toku_free(pd->name.name);
toku_free(pd);
}
static void write_uchar_to_dbt (DBT *dbt, const unsigned char c) {
......@@ -101,7 +101,7 @@ static void read_name_from_dbt (const DBT *dbt, unsigned int *off, struct name_k
read_uchar_from_dbt(dbt, off, &buf[i]);
if (buf[i]==0) break;
}
nk->name=(unsigned char*)(strdup((char*)buf));
nk->name=(unsigned char*)(toku_strdup((char*)buf));
}
static void read_pd_from_dbt (const DBT *dbt, unsigned int *off, struct primary_data *pd) {
......@@ -112,7 +112,7 @@ static void read_pd_from_dbt (const DBT *dbt, unsigned int *off, struct primary_
}
static int name_callback (DB *secondary __attribute__((__unused__)), const DBT * UU(key), const DBT *data, DBT *result) {
struct primary_data *pd = malloc(sizeof(*pd));
struct primary_data *pd = toku_malloc(sizeof(*pd));
unsigned int off=0;
read_pd_from_dbt(data, &off, pd);
static int buf[1000];
......@@ -167,8 +167,8 @@ static void close_databases (void) {
if (name_cursor) {
r = name_cursor->c_close(name_cursor); CKERR(r);
}
if (nc_key.data) free(nc_key.data);
if (nc_data.data) free(nc_data.data);
if (nc_key.data) toku_free(nc_key.data);
if (nc_data.data) toku_free(nc_data.data);
r = namedb->close(namedb, 0); CKERR(r);
r = dbp->close(dbp, 0); CKERR(r);
r = expiredb->close(expiredb, 0); CKERR(r);
......@@ -307,10 +307,10 @@ test_main (int argc, const char *argv[]) {
memset(&nc_key, 0, sizeof(nc_key));
memset(&nc_data, 0, sizeof(nc_data));
nc_key.flags = DB_DBT_MALLOC;
nc_key.data = malloc(1); // Initalize it.
nc_key.data = toku_malloc(1); // Initalize it.
((char*)nc_key.data)[0]=0;
nc_data.flags = DB_DBT_MALLOC;
nc_data.data = malloc(1); // Initalize it.
nc_data.data = toku_malloc(1); // Initalize it.
mode = MODE_DEFAULT;
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
#include <string.h>
#include <memory.h>
#include <toku_portability.h>
#include <db.h>
#include <assert.h>
......@@ -28,7 +28,7 @@ static DB_ENV *dbenv;
static __attribute__((__unused__)) void* lastmalloced;
static void* my_malloc(size_t size) {
void* p = malloc(size);
void* p = toku_malloc(size);
return p;
}
......@@ -45,7 +45,7 @@ my_free(void * p) {
if (verbose) printf("Freeing %p.\n", p);
lastmalloced = NULL;
}
free(p);
toku_free(p);
}
/*
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
#include <string.h>
#include <memory.h>
#include <toku_portability.h>
#include <db.h>
#include <assert.h>
......@@ -27,7 +27,7 @@ int nummallocced = 0;
static void *
my_malloc (size_t size) {
void* p = malloc(size);
void* p = toku_malloc(size);
if (size != 0) {
nummallocced++;
// if (verbose) printf("Malloc [%d] %p.\n", (int)size, p);
......@@ -49,7 +49,7 @@ my_free (void * p) {
nummallocced--;
// if (verbose) printf("Free %p.\n", p);
}
free(p);
toku_free(p);
}
/*
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
#include <string.h>
#include <memory.h>
#include <toku_portability.h>
#include <db.h>
#include <assert.h>
......@@ -99,7 +99,7 @@ test_main(int argc, const char *argv[]) {
dbt_init(&key, &key_1, sizeof(key_1));
dbt_init(&data, 0, 0);
data.flags = flags[j];
oldmem = malloc(set_ulen);
oldmem = toku_malloc(set_ulen);
data.data = oldmem;
memset(oldmem, 0, set_ulen);
if (flags[j] == DB_DBT_USERMEM) {
......@@ -126,10 +126,10 @@ test_main(int argc, const char *argv[]) {
doclone = r == 0;
if (flags[j] != 0) {
free(data.data);
toku_free(data.data);
}
if (flags[j] == 0 || flags[j] == DB_DBT_MALLOC) {
free(oldmem);
toku_free(oldmem);
}
assert(!was_truncated);
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <errno.h>
#include <sys/stat.h>
#include <toku_portability.h>
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <errno.h>
#include <sys/stat.h>
#include <toku_portability.h>
......@@ -129,7 +129,7 @@ test_db_get_datasize0 (void) {
DBT key, val;
r = db->get(db, 0, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), 0);
assert(r == 0);
free(val.data);
toku_free(val.data);
r = db->close(db, 0);
assert(r == 0);
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
#include <string.h>
#include <memory.h>
#include <toku_portability.h>
#include <db.h>
#include <assert.h>
......@@ -57,7 +57,7 @@ getskey (DB *UU(secondary), const DBT *UU(pkey), const DBT *pdata, DBT *skey)
if (callback_init_data) {
skey->size = sizeof(entry->skey);
if (callback_set_malloc) {
skey->data = malloc(skey->size);
skey->data = toku_malloc(skey->size);
memcpy(skey->data, &entry->skey, skey->size);
}
else skey->data = &entry->skey;
......
......@@ -10,7 +10,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <memory.h>
// ENVDIR is defined in the Makefile
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
#include <string.h>
#include <memory.h>
#include <toku_portability.h>
#include <db.h>
#include <assert.h>
......
......@@ -8,7 +8,7 @@
#include <errno.h>
#include <toku_portability.h>
#include <db.h>
#include <string.h>
#include <memory.h>
#include "test.h"
......
......@@ -8,7 +8,7 @@
#include <errno.h>
#include <toku_portability.h>
#include <db.h>
#include <string.h>
#include <memory.h>
#include "test.h"
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
#include <string.h>
#include <memory.h>
#include <toku_portability.h>
#include <db.h>
#include <assert.h>
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <errno.h>
#include <sys/stat.h>
#include <toku_portability.h>
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
#include <string.h>
#include <memory.h>
#include <toku_portability.h>
#include <db.h>
#include <assert.h>
......
/* -*- mode: C; c-basic-offset: 4 -*- */
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
#include <string.h>
#include <memory.h>
#include <toku_portability.h>
#include <db.h>
#include <assert.h>
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......@@ -35,8 +35,8 @@ expect (DBC *cursor, int k, int v) {
assert(kk == k);
assert(vv == v);
free(key.data);
free(val.data);
toku_free(key.data);
toku_free(val.data);
}
/* verify dup keys delete */
......@@ -97,7 +97,7 @@ test_dup_delete (int n, int dup_mode) {
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == htonl(n));
free(val.data);
toku_free(val.data);
}
{
......@@ -273,7 +273,7 @@ test_dup_delete_insert (int n, int dup_mode) {
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == htonl(0));
free(val.data);
toku_free(val.data);
}
{
......@@ -296,7 +296,7 @@ test_dup_delete_insert (int n, int dup_mode) {
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == htonl(0));
free(val.data);
toku_free(val.data);
}
DBC *cursor;
......@@ -509,7 +509,7 @@ test_icdi_search (int n, int dup_mode) {
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == htonl(0));
free(val.data);
toku_free(val.data);
}
/* reopen the database to force nonleaf buffering */
......@@ -544,7 +544,7 @@ test_icdi_search (int n, int dup_mode) {
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == htonl(n));
free(val.data);
toku_free(val.data);
}
DBC *cursor;
......@@ -600,7 +600,7 @@ test_ici_search (int n, int dup_mode) {
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == htonl(0));
free(val.data);
toku_free(val.data);
}
/* reopen the database to force nonleaf buffering */
......@@ -628,7 +628,7 @@ test_ici_search (int n, int dup_mode) {
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == htonl(0));
free(val.data);
toku_free(val.data);
}
DBC *cursor;
......@@ -656,7 +656,7 @@ expect_db_lookup (DB *db, int k, int v) {
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == v);
free(val.data);
toku_free(val.data);
}
/* insert 0, insert 1, close, insert 0, search 0 */
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......@@ -99,8 +99,8 @@ test_dup_key (int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdupdup)
memcpy(&kk, key.data, key.size);
memcpy(&vv, val.data, val.size);
if (verbose) printf("kk %d vv %d\n", kk, vv);
free(key.data);
free(val.data);
toku_free(key.data);
toku_free(val.data);
}
r = cursor->c_close(cursor); assert(r == 0);
......@@ -151,8 +151,8 @@ test_dup_dup (int dup_mode, u_int32_t put_flags, int rexpect, int rexpectdupdup)
memcpy(&kk, key.data, key.size);
memcpy(&vv, val.data, val.size);
if (verbose) printf("kk %d vv %d\n", kk, vv);
free(key.data);
free(val.data);
toku_free(key.data);
toku_free(val.data);
}
r = cursor->c_close(cursor); assert(r == 0);
......@@ -209,8 +209,8 @@ test_put_00_01_01 (int dup_mode, u_int32_t put_flags) {
memcpy(&kk, key.data, key.size);
memcpy(&vv, val.data, val.size);
if (verbose) printf("kk %d vv %d\n", kk, vv);
free(key.data);
free(val.data);
toku_free(key.data);
toku_free(val.data);
}
r = cursor->c_close(cursor); assert(r == 0);
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......@@ -35,8 +35,8 @@ expect (DBC *cursor, int k, int v) {
assert(kk == k);
assert(vv == v);
free(key.data);
free(val.data);
toku_free(key.data);
toku_free(val.data);
}
static int mycmp(const void *a, const void *b) {
......@@ -109,7 +109,7 @@ test_insert (int n, int dup_mode) {
assert(vv == values[n-1]);
} else
assert(vv == values[i]);
free(val.data);
toku_free(val.data);
}
/* verify the sort order with a cursor */
......@@ -218,7 +218,7 @@ test_nonleaf_insert (int n, int dup_mode) {
assert(vv == values[n-1]);
} else
assert(vv == values[i]);
free(val.data);
toku_free(val.data);
}
/* verify the sort order with a cursor */
......
......@@ -7,7 +7,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <errno.h>
#include <sys/stat.h>
#include <toku_portability.h>
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......@@ -40,7 +40,7 @@ expect_db_get (DB *db, int k, int v) {
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == v);
free(val.data);
toku_free(val.data);
}
static void
......@@ -58,8 +58,8 @@ expect_cursor_get (DBC *cursor, int k, int v) {
assert(kk == k);
assert(vv == v);
free(key.data);
free(val.data);
toku_free(key.data);
toku_free(val.data);
}
/* insert, close, delete, insert, search */
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......@@ -40,7 +40,7 @@ expect_db_get (DB *db, int k, int v) {
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == v);
free(val.data);
toku_free(val.data);
}
static void
......@@ -48,7 +48,7 @@ expect_cursor_set (DBC *cursor, int k) {
DBT key, val;
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET);
assert(r == 0);
free(val.data);
toku_free(val.data);
}
static void
......@@ -59,7 +59,7 @@ expect_cursor_get_current (DBC *cursor, int k, int v) {
int kk, vv;
assert(key.size == sizeof kk); memcpy(&kk, key.data, key.size); assert(kk == k);
assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v);
free(key.data); free(val.data);
toku_free(key.data); toku_free(val.data);
}
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......@@ -38,7 +38,7 @@ expect_db_get (DB *db, int k, int v) {
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == v);
free(val.data);
toku_free(val.data);
}
static void
......@@ -56,8 +56,8 @@ expect_cursor_get (DBC *cursor, int k, int v) {
assert(kk == k);
assert(vv == v);
free(key.data);
free(val.data);
toku_free(key.data);
toku_free(val.data);
}
static void
......@@ -75,7 +75,7 @@ expect_cursor_get_current (DBC *cursor, int k, int v) {
int kk, vv;
assert(key.size == sizeof kk); memcpy(&kk, key.data, key.size); assert(kk == k);
assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v);
free(key.data); free(val.data);
toku_free(key.data); toku_free(val.data);
}
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......@@ -38,7 +38,7 @@ expect_db_get (DB *db, int k, int v) {
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == v);
free(val.data);
toku_free(val.data);
}
static void
......@@ -56,8 +56,8 @@ expect_cursor_get (DBC *cursor, int k, int v) {
assert(kk == k);
assert(vv == v);
free(key.data);
free(val.data);
toku_free(key.data);
toku_free(val.data);
}
static void
......@@ -75,7 +75,7 @@ expect_cursor_get_current (DBC *cursor, int k, int v) {
int kk, vv;
assert(key.size == sizeof kk); memcpy(&kk, key.data, key.size); assert(kk == k);
assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v);
free(key.data); free(val.data);
toku_free(key.data); toku_free(val.data);
}
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......@@ -38,7 +38,7 @@ expect_db_get (DB *db, int k, int v) {
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == v);
free(val.data);
toku_free(val.data);
}
static void
......@@ -56,8 +56,8 @@ expect_cursor_get (DBC *cursor, int k, int v) {
assert(kk == k);
assert(vv == v);
free(key.data);
free(val.data);
toku_free(key.data);
toku_free(val.data);
}
static void
......@@ -65,7 +65,7 @@ expect_cursor_set (DBC *cursor, int k) {
DBT key, val;
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET);
assert(r == 0);
free(val.data);
toku_free(val.data);
}
static void
......@@ -76,7 +76,7 @@ expect_cursor_get_current (DBC *cursor, int k, int v) {
int kk, vv;
assert(key.size == sizeof kk); memcpy(&kk, key.data, key.size); assert(kk == k);
assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v);
free(key.data); free(val.data);
toku_free(key.data); toku_free(val.data);
}
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......@@ -45,7 +45,7 @@ expect_db_get (DB *db, int k, int v) {
assert(val.size == sizeof vv);
memcpy(&vv, val.data, val.size);
assert(vv == v);
free(val.data);
toku_free(val.data);
}
static void
......@@ -63,8 +63,8 @@ expect_cursor_get (DBC *cursor, int k, int v) {
assert(kk == k);
assert(vv == v);
free(key.data);
free(val.data);
toku_free(key.data);
toku_free(val.data);
}
static void
......@@ -72,7 +72,7 @@ expect_cursor_set_range (DBC *cursor, int k) {
DBT key, val;
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET_RANGE);
assert(r == 0);
free(val.data);
toku_free(val.data);
}
static void
......@@ -83,7 +83,7 @@ expect_cursor_get_current (DBC *cursor, int k, int v) {
int kk, vv;
assert(key.size == sizeof kk); memcpy(&kk, key.data, key.size); assert(kk == k);
assert(val.size == sizeof vv); memcpy(&vv, val.data, val.size); assert(vv == v);
free(key.data); free(val.data);
toku_free(key.data); toku_free(val.data);
}
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <errno.h>
#include <sys/stat.h>
#include <toku_portability.h>
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......
......@@ -2,7 +2,7 @@
#include <toku_portability.h>
#include <db.h>
#include <string.h>
#include <memory.h>
#include <stdlib.h>
#include <assert.h>
#include <sys/stat.h>
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......@@ -92,7 +92,7 @@ test_hsoc (int pagesize, int dup_mode) {
DBT key, val;
r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_FIRST); assert(r == 0);
free(key.data); free(val.data);
toku_free(key.data); toku_free(val.data);
/* fill up buffer 2 in the root node */
for (i=0; i<216; i++) {
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......@@ -40,23 +40,23 @@ test_insert_delete_insert (int dup_mode) {
r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET);
assert(r == 0);
free(val.data);
toku_free(val.data);
r = cursor->c_del(cursor, 0);
assert(r == 0);
r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT);
assert(r == DB_KEYEMPTY);
if (key.data) free(key.data);
if (val.data) free(val.data);
if (key.data) toku_free(key.data);
if (val.data) toku_free(val.data);
r = db->put(db, null_txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), DB_YESOVERWRITE);
assert(r == 0);
r = cursor->c_get(cursor, dbt_init_malloc(&key), dbt_init_malloc(&val), DB_CURRENT);
assert(r == 0);
if (key.data) free(key.data);
if (val.data) free(val.data);
if (key.data) toku_free(key.data);
if (val.data) toku_free(val.data);
r = cursor->c_close(cursor); assert(r == 0);
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......
......@@ -5,7 +5,7 @@
#include <stdlib.h>
#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
......@@ -62,8 +62,8 @@ test_key_size_limit (int dup_mode) {
hi = mi-1;
}
}
free(k);
free(v);
toku_free(k);
toku_free(v);
assert(bigest > 0);
if (verbose) printf("%s bigest %u\n", __FUNCTION__, bigest);
......@@ -118,8 +118,8 @@ test_data_size_limit (int dup_mode) {
hi = mi-1;
}
}
free(k);
free(v);
toku_free(k);
toku_free(v);
if (verbose && bigest > 0) printf("%s bigest %u\n", __FUNCTION__, bigest);
r = db->close(db, 0);
......
......@@ -8,7 +8,7 @@
#include <sys/types.h>
#include <toku_portability.h>
#include <db.h>
#include <string.h>
#include <memory.h>
#include <stdio.h>
#include <errno.h>
......
......@@ -14,7 +14,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <memory.h>
// ENVDIR is defined in the Makefile
......@@ -47,7 +47,7 @@ static void insert_some (int outeri) {
for (i=0; i<maxcount; i++) {
char hello[30], there[30];
DBT key,data;
struct in_db *newitem = malloc(sizeof(*newitem));
struct in_db *newitem = toku_malloc(sizeof(*newitem));
newitem->r = random();
newitem->i = i;
newitem->next = items;
......@@ -96,7 +96,7 @@ static void make_db (void) {
while (items) {
struct in_db *next=items->next;
free(items);
toku_free(items);
items=next;
}
}
......
......@@ -9,7 +9,7 @@
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <unistd.h>
......
......@@ -12,7 +12,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <memory.h>
// ENVDIR is defined in the Makefile
......
......@@ -11,7 +11,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <memory.h>
// ENVDIR is defined in the Makefile
......
......@@ -12,7 +12,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <memory.h>
// ENVDIR is defined in the Makefile
......
......@@ -11,7 +11,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <memory.h>
// ENVDIR is defined in the Makefile
......
......@@ -12,7 +12,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <memory.h>
// ENVDIR is defined in the Makefile
......@@ -46,7 +46,7 @@ static void make_db (void) {
for (i=0; i<maxcount; i++) {
char hello[30], there[30];
DBT key,data;
struct in_db *newitem = malloc(sizeof(*newitem));
struct in_db *newitem = toku_malloc(sizeof(*newitem));
newitem->r = random();
newitem->i = i;
newitem->next = items;
......@@ -64,7 +64,7 @@ static void make_db (void) {
r=env->close(env, 0); assert(r==0);
while (items) {
struct in_db *next=items->next;
free(items);
toku_free(items);
items=next;
}
}
......
......@@ -11,7 +11,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <memory.h>
// ENVDIR is defined in the Makefile
......@@ -45,7 +45,7 @@ static void make_db (void) {
for (i=0; i<maxcount; i++) {
char hello[30], there[30];
DBT key,data;
struct in_db *newitem = malloc(sizeof(*newitem));
struct in_db *newitem = toku_malloc(sizeof(*newitem));
newitem->r = random();
newitem->i = i;
newitem->next = items;
......@@ -76,7 +76,7 @@ static void make_db (void) {
r=env->close(env, 0); assert(r==0);
while (items) {
struct in_db *next=items->next;
free(items);
toku_free(items);
items=next;
}
}
......
......@@ -12,7 +12,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <memory.h>
#ifndef DB_DELETE_ANY
#define DB_DELETE_ANY 0
......@@ -30,7 +30,7 @@ struct in_db {
static void put_n (DB *db, DB_TXN *tid, int i) {
char hello[30], there[30];
DBT key,data;
struct in_db *newitem = malloc(sizeof(*newitem));
struct in_db *newitem = toku_malloc(sizeof(*newitem));
newitem->r = random();
newitem->i = i;
newitem->next = items;
......@@ -98,13 +98,13 @@ static void make_db (void) {
r=env->close(env, 0); assert(r==0);
while (items) {
struct in_db *next=items->next;
free(items);
toku_free(items);
items=next;
}
while (deleted_items) {
struct in_db *next=deleted_items->next;
free(deleted_items);
toku_free(deleted_items);
deleted_items=next;
}
}
......
......@@ -11,7 +11,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <memory.h>
#ifndef DB_DELETE_ANY
#define DB_DELETE_ANY 0
......@@ -29,7 +29,7 @@ struct in_db {
static void put_n (DB *db, DB_TXN *tid, int i) {
char hello[30], there[30];
DBT key,data;
struct in_db *newitem = malloc(sizeof(*newitem));
struct in_db *newitem = toku_malloc(sizeof(*newitem));
newitem->r = random();
newitem->i = i;
newitem->next = items;
......@@ -110,13 +110,13 @@ static void make_db (void) {
r=env->close(env, 0); assert(r==0);
while (items) {
struct in_db *next=items->next;
free(items);
toku_free(items);
items=next;
}
while (deleted_items) {
struct in_db *next=deleted_items->next;
free(deleted_items);
toku_free(deleted_items);
deleted_items=next;
}
}
......
......@@ -11,7 +11,7 @@
#include <search.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <memory.h>
#include "test.h"
......
......@@ -13,7 +13,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <memory.h>
// ENVDIR is defined in the Makefile
......@@ -49,7 +49,7 @@ static void make_db (void) {
for (i=0; i<maxcount; i++) {
char hello[30], there[30];
DBT key,data;
struct in_db *newitem = malloc(sizeof(*newitem));
struct in_db *newitem = toku_malloc(sizeof(*newitem));
newitem->r = random();
newitem->i = i;
newitem->next = items;
......@@ -74,7 +74,7 @@ static void make_db (void) {
r=env->close(env, 0); assert(r==0);
while (items) {
struct in_db *next=items->next;
free(items);
toku_free(items);
items=next;
}
}
......
......@@ -13,7 +13,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <memory.h>
// ENVDIR is defined in the Makefile
......@@ -46,7 +46,7 @@ static void insert_some (int outeri) {
for (i=0; i<maxcount; i++) {
char hello[30], there[30];
DBT key,data;
struct in_db *newitem = malloc(sizeof(*newitem));
struct in_db *newitem = toku_malloc(sizeof(*newitem));
newitem->r = random();
newitem->i = i;
newitem->next = items;
......@@ -88,7 +88,7 @@ static void make_db (void) {
while (items) {
struct in_db *next=items->next;
free(items);
toku_free(items);
items=next;
}
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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