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 source diff could not be displayed because it is too large. You can view the blob instead.
/*
Default header file for malloc-2.8.x, written by Doug Lea
and released to the public domain, as explained at
http://creativecommons.org/licenses/publicdomain.
last update: Mon Aug 15 08:55:52 2005 Doug Lea (dl at gee)
This header is for ANSI C/C++ only. You can set any of
the following #defines before including:
* If USE_DL_PREFIX is defined, it is assumed that malloc.c
was also compiled with this option, so all routines
have names starting with "dl".
* If HAVE_USR_INCLUDE_MALLOC_H is defined, it is assumed that this
file will be #included AFTER <malloc.h>. This is needed only if
your system defines a struct mallinfo that is incompatible with the
standard one declared here. Otherwise, you can include this file
INSTEAD of your system system <malloc.h>. At least on ANSI, all
declarations should be compatible with system versions
* If MSPACES is defined, declarations for mspace versions are included.
*/
#ifndef MALLOC_280_H
#define MALLOC_280_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h> /* for size_t */
#if !ONLY_MSPACES
#ifndef USE_DL_PREFIX
#define dlcalloc calloc
#define dlfree free
#define dlmalloc malloc
#define dlmemalign memalign
#define dlrealloc realloc
#define dlvalloc valloc
#define dlpvalloc pvalloc
#define dlmallinfo mallinfo
#define dlmallopt mallopt
#define dlmalloc_trim malloc_trim
#define dlmalloc_stats malloc_stats
#define dlmalloc_usable_size malloc_usable_size
#define dlmalloc_footprint malloc_footprint
#define dlindependent_calloc independent_calloc
#define dlindependent_comalloc independent_comalloc
#endif /* USE_DL_PREFIX */
/*
malloc(size_t n)
Returns a pointer to a newly allocated chunk of at least n bytes, or
null if no space is available, in which case errno is set to ENOMEM
on ANSI C systems.
If n is zero, malloc returns a minimum-sized chunk. (The minimum
size is 16 bytes on most 32bit systems, and 32 bytes on 64bit
systems.) Note that size_t is an unsigned type, so calls with
arguments that would be negative if signed are interpreted as
requests for huge amounts of space, which will often fail. The
maximum supported value of n differs across systems, but is in all
cases less than the maximum representable value of a size_t.
*/
void* dlmalloc(size_t);
/*
free(void* p)
Releases the chunk of memory pointed to by p, that had been previously
allocated using malloc or a related routine such as realloc.
It has no effect if p is null. If p was not malloced or already
freed, free(p) will by default cuase the current program to abort.
*/
void dlfree(void*);
/*
calloc(size_t n_elements, size_t element_size);
Returns a pointer to n_elements * element_size bytes, with all locations
set to zero.
*/
void* dlcalloc(size_t, size_t);
/*
realloc(void* p, size_t n)
Returns a pointer to a chunk of size n that contains the same data
as does chunk p up to the minimum of (n, p's size) bytes, or null
if no space is available.
The returned pointer may or may not be the same as p. The algorithm
prefers extending p in most cases when possible, otherwise it
employs the equivalent of a malloc-copy-free sequence.
If p is null, realloc is equivalent to malloc.
If space is not available, realloc returns null, errno is set (if on
ANSI) and p is NOT freed.
if n is for fewer bytes than already held by p, the newly unused
space is lopped off and freed if possible. realloc with a size
argument of zero (re)allocates a minimum-sized chunk.
The old unix realloc convention of allowing the last-free'd chunk
to be used as an argument to realloc is not supported.
*/
void* dlrealloc(void*, size_t);
/*
memalign(size_t alignment, size_t n);
Returns a pointer to a newly allocated chunk of n bytes, aligned
in accord with the alignment argument.
The alignment argument should be a power of two. If the argument is
not a power of two, the nearest greater power is used.
8-byte alignment is guaranteed by normal malloc calls, so don't
bother calling memalign with an argument of 8 or less.
Overreliance on memalign is a sure way to fragment space.
*/
void* dlmemalign(size_t, size_t);
/*
valloc(size_t n);
Equivalent to memalign(pagesize, n), where pagesize is the page
size of the system. If the pagesize is unknown, 4096 is used.
*/
void* dlvalloc(size_t);
/*
mallopt(int parameter_number, int parameter_value)
Sets tunable parameters The format is to provide a
(parameter-number, parameter-value) pair. mallopt then sets the
corresponding parameter to the argument value if it can (i.e., so
long as the value is meaningful), and returns 1 if successful else
0. SVID/XPG/ANSI defines four standard param numbers for mallopt,
normally defined in malloc.h. None of these are use in this malloc,
so setting them has no effect. But this malloc also supports other
options in mallopt:
Symbol param # default allowed param values
M_TRIM_THRESHOLD -1 2*1024*1024 any (-1U disables trimming)
M_GRANULARITY -2 page size any power of 2 >= page size
M_MMAP_THRESHOLD -3 256*1024 any (or 0 if no MMAP support)
*/
int dlmallopt(int, int);
#define M_TRIM_THRESHOLD (-1)
#define M_GRANULARITY (-2)
#define M_MMAP_THRESHOLD (-3)
/*
malloc_footprint();
Returns the number of bytes obtained from the system. The total
number of bytes allocated by malloc, realloc etc., is less than this
value. Unlike mallinfo, this function returns only a precomputed
result, so can be called frequently to monitor memory consumption.
Even if locks are otherwise defined, this function does not use them,
so results might not be up to date.
*/
size_t dlmalloc_footprint();
#if !NO_MALLINFO
/*
mallinfo()
Returns (by copy) a struct containing various summary statistics:
arena: current total non-mmapped bytes allocated from system
ordblks: the number of free chunks
smblks: always zero.
hblks: current number of mmapped regions
hblkhd: total bytes held in mmapped regions
usmblks: the maximum total allocated space. This will be greater
than current total if trimming has occurred.
fsmblks: always zero
uordblks: current total allocated space (normal or mmapped)
fordblks: total free space
keepcost: the maximum number of bytes that could ideally be released
back to system via malloc_trim. ("ideally" means that
it ignores page restrictions etc.)
Because these fields are ints, but internal bookkeeping may
be kept as longs, the reported values may wrap around zero and
thus be inaccurate.
*/
#ifndef HAVE_USR_INCLUDE_MALLOC_H
#ifndef _MALLOC_H
#ifndef MALLINFO_FIELD_TYPE
#define MALLINFO_FIELD_TYPE size_t
#endif /* MALLINFO_FIELD_TYPE */
struct mallinfo {
MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */
MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */
MALLINFO_FIELD_TYPE smblks; /* always 0 */
MALLINFO_FIELD_TYPE hblks; /* always 0 */
MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */
MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */
MALLINFO_FIELD_TYPE fsmblks; /* always 0 */
MALLINFO_FIELD_TYPE uordblks; /* total allocated space */
MALLINFO_FIELD_TYPE fordblks; /* total free space */
MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */
};
#endif /* _MALLOC_H */
#endif /* HAVE_USR_INCLUDE_MALLOC_H */
struct mallinfo dlmallinfo(void);
#endif /* NO_MALLINFO */
/*
independent_calloc(size_t n_elements, size_t element_size, void* chunks[]);
independent_calloc is similar to calloc, but instead of returning a
single cleared space, it returns an array of pointers to n_elements
independent elements that can hold contents of size elem_size, each
of which starts out cleared, and can be independently freed,
realloc'ed etc. The elements are guaranteed to be adjacently
allocated (this is not guaranteed to occur with multiple callocs or
mallocs), which may also improve cache locality in some
applications.
The "chunks" argument is optional (i.e., may be null, which is
probably the most typical usage). If it is null, the returned array
is itself dynamically allocated and should also be freed when it is
no longer needed. Otherwise, the chunks array must be of at least
n_elements in length. It is filled in with the pointers to the
chunks.
In either case, independent_calloc returns this pointer array, or
null if the allocation failed. If n_elements is zero and "chunks"
is null, it returns a chunk representing an array with zero elements
(which should be freed if not wanted).
Each element must be individually freed when it is no longer
needed. If you'd like to instead be able to free all at once, you
should instead use regular calloc and assign pointers into this
space to represent elements. (In this case though, you cannot
independently free elements.)
independent_calloc simplifies and speeds up implementations of many
kinds of pools. It may also be useful when constructing large data
structures that initially have a fixed number of fixed-sized nodes,
but the number is not known at compile time, and some of the nodes
may later need to be freed. For example:
struct Node { int item; struct Node* next; };
struct Node* build_list() {
struct Node** pool;
int n = read_number_of_nodes_needed();
if (n <= 0) return 0;
pool = (struct Node**)(independent_calloc(n, sizeof(struct Node), 0);
if (pool == 0) die();
// organize into a linked list...
struct Node* first = pool[0];
for (i = 0; i < n-1; ++i)
pool[i]->next = pool[i+1];
free(pool); // Can now free the array (or not, if it is needed later)
return first;
}
*/
void** dlindependent_calloc(size_t, size_t, void**);
/*
independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]);
independent_comalloc allocates, all at once, a set of n_elements
chunks with sizes indicated in the "sizes" array. It returns
an array of pointers to these elements, each of which can be
independently freed, realloc'ed etc. The elements are guaranteed to
be adjacently allocated (this is not guaranteed to occur with
multiple callocs or mallocs), which may also improve cache locality
in some applications.
The "chunks" argument is optional (i.e., may be null). If it is null
the returned array is itself dynamically allocated and should also
be freed when it is no longer needed. Otherwise, the chunks array
must be of at least n_elements in length. It is filled in with the
pointers to the chunks.
In either case, independent_comalloc returns this pointer array, or
null if the allocation failed. If n_elements is zero and chunks is
null, it returns a chunk representing an array with zero elements
(which should be freed if not wanted).
Each element must be individually freed when it is no longer
needed. If you'd like to instead be able to free all at once, you
should instead use a single regular malloc, and assign pointers at
particular offsets in the aggregate space. (In this case though, you
cannot independently free elements.)
independent_comallac differs from independent_calloc in that each
element may have a different size, and also that it does not
automatically clear elements.
independent_comalloc can be used to speed up allocation in cases
where several structs or objects must always be allocated at the
same time. For example:
struct Head { ... }
struct Foot { ... }
void send_message(char* msg) {
int msglen = strlen(msg);
size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) };
void* chunks[3];
if (independent_comalloc(3, sizes, chunks) == 0)
die();
struct Head* head = (struct Head*)(chunks[0]);
char* body = (char*)(chunks[1]);
struct Foot* foot = (struct Foot*)(chunks[2]);
// ...
}
In general though, independent_comalloc is worth using only for
larger values of n_elements. For small values, you probably won't
detect enough difference from series of malloc calls to bother.
Overuse of independent_comalloc can increase overall memory usage,
since it cannot reuse existing noncontiguous small chunks that
might be available for some of the elements.
*/
void** dlindependent_comalloc(size_t, size_t*, void**);
/*
pvalloc(size_t n);
Equivalent to valloc(minimum-page-that-holds(n)), that is,
round up n to nearest pagesize.
*/
void* dlpvalloc(size_t);
/*
malloc_trim(size_t pad);
If possible, gives memory back to the system (via negative arguments
to sbrk) if there is unused memory at the `high' end of the malloc
pool or in unused MMAP segments. You can call this after freeing
large blocks of memory to potentially reduce the system-level memory
requirements of a program. However, it cannot guarantee to reduce
memory. Under some allocation patterns, some large free blocks of
memory will be locked between two used chunks, so they cannot be
given back to the system.
The `pad' argument to malloc_trim represents the amount of free
trailing space to leave untrimmed. If this argument is zero, only
the minimum amount of memory to maintain internal data structures
will be left. Non-zero arguments can be supplied to maintain enough
trailing space to service future expected allocations without having
to re-obtain memory from the system.
Malloc_trim returns 1 if it actually released any memory, else 0.
*/
int dlmalloc_trim(size_t);
/*
malloc_usable_size(void* p);
Returns the number of bytes you can actually use in
an allocated chunk, which may be more than you requested (although
often not) due to alignment and minimum size constraints.
You can use this many bytes without worrying about
overwriting other allocated objects. This is not a particularly great
programming practice. malloc_usable_size can be more useful in
debugging and assertions, for example:
p = malloc(n);
assert(malloc_usable_size(p) >= 256);
*/
size_t dlmalloc_usable_size(void*);
/*
malloc_stats();
Prints on stderr the amount of space obtained from the system (both
via sbrk and mmap), the maximum amount (which may be more than
current if malloc_trim and/or munmap got called), and the current
number of bytes allocated via malloc (or realloc, etc) but not yet
freed. Note that this is the number of bytes allocated, not the
number requested. It will be larger than the number requested
because of alignment and bookkeeping overhead. Because it includes
alignment wastage as being in use, this figure may be greater than
zero even when no user-level chunks are allocated.
The reported current and maximum system memory can be inaccurate if
a program makes other calls to system memory allocation functions
(normally sbrk) outside of malloc.
malloc_stats prints only the most commonly interesting statistics.
More information can be obtained by calling mallinfo.
*/
void dlmalloc_stats();
#endif /* !ONLY_MSPACES */
#if MSPACES
/*
mspace is an opaque type representing an independent
region of space that supports mspace_malloc, etc.
*/
typedef void* mspace;
/*
create_mspace creates and returns a new independent space with the
given initial capacity, or, if 0, the default granularity size. It
returns null if there is no system memory available to create the
space. If argument locked is non-zero, the space uses a separate
lock to control access. The capacity of the space will grow
dynamically as needed to service mspace_malloc requests. You can
control the sizes of incremental increases of this space by
compiling with a different DEFAULT_GRANULARITY or dynamically
setting with mallopt(M_GRANULARITY, value).
*/
mspace create_mspace(size_t capacity, int locked);
/*
destroy_mspace destroys the given space, and attempts to return all
of its memory back to the system, returning the total number of
bytes freed. After destruction, the results of access to all memory
used by the space become undefined.
*/
size_t destroy_mspace(mspace msp);
/*
create_mspace_with_base uses the memory supplied as the initial base
of a new mspace. Part (less than 128*sizeof(size_t) bytes) of this
space is used for bookkeeping, so the capacity must be at least this
large. (Otherwise 0 is returned.) When this initial space is
exhausted, additional memory will be obtained from the system.
Destroying this space will deallocate all additionally allocated
space (if possible) but not the initial base.
*/
mspace create_mspace_with_base(void* base, size_t capacity, int locked);
/*
mspace_malloc behaves as malloc, but operates within
the given space.
*/
void* mspace_malloc(mspace msp, size_t bytes);
/*
mspace_free behaves as free, but operates within
the given space.
If compiled with FOOTERS==1, mspace_free is not actually needed.
free may be called instead of mspace_free because freed chunks from
any space are handled by their originating spaces.
*/
void mspace_free(mspace msp, void* mem);
/*
mspace_realloc behaves as realloc, but operates within
the given space.
If compiled with FOOTERS==1, mspace_realloc is not actually
needed. realloc may be called instead of mspace_realloc because
realloced chunks from any space are handled by their originating
spaces.
*/
void* mspace_realloc(mspace msp, void* mem, size_t newsize);
/*
mspace_calloc behaves as calloc, but operates within
the given space.
*/
void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size);
/*
mspace_memalign behaves as memalign, but operates within
the given space.
*/
void* mspace_memalign(mspace msp, size_t alignment, size_t bytes);
/*
mspace_independent_calloc behaves as independent_calloc, but
operates within the given space.
*/
void** mspace_independent_calloc(mspace msp, size_t n_elements,
size_t elem_size, void* chunks[]);
/*
mspace_independent_comalloc behaves as independent_comalloc, but
operates within the given space.
*/
void** mspace_independent_comalloc(mspace msp, size_t n_elements,
size_t sizes[], void* chunks[]);
/*
mspace_footprint() returns the number of bytes obtained from the
system for this space.
*/
size_t mspace_footprint(mspace msp);
#if !NO_MALLINFO
/*
mspace_mallinfo behaves as mallinfo, but reports properties of
the given space.
*/
struct mallinfo mspace_mallinfo(mspace msp);
#endif /* NO_MALLINFO */
/*
mspace_malloc_stats behaves as malloc_stats, but reports
properties of the given space.
*/
void mspace_malloc_stats(mspace msp);
/*
mspace_trim behaves as malloc_trim, but
operates within the given space.
*/
int mspace_trim(mspace msp, size_t pad);
/*
An alias for mallopt.
*/
int mspace_mallopt(int, int);
#endif /* MSPACES */
#ifdef __cplusplus
}; /* end of extern "C" */
#endif
#endif /* MALLOC_280_H */
......@@ -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;
}
}
......
......@@ -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;
}
}
......
......@@ -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);
}
static void
......@@ -67,7 +67,7 @@ expect_cursor_set (DBC *cursor, int k, int expectr) {
DBT key, val;
int r = cursor->c_get(cursor, dbt_init(&key, &k, sizeof k), dbt_init_malloc(&val), DB_SET);
assert(r == expectr);
if (val.data) free(val.data);
if (val.data) toku_free(val.data);
}
static void
......@@ -78,7 +78,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>
......@@ -75,7 +75,7 @@ test_rand_insert (int n, int dup_mode) {
memcpy(&vv, val.data, val.size);
if (vv != i) assert(keys[vv] == keys[i]);
else assert(vv == i);
free(val.data);
toku_free(val.data);
}
r = db->close(db, 0);
......
......@@ -9,7 +9,7 @@
#include <db.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
......@@ -49,8 +49,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 void
......
......@@ -11,7 +11,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
#include <memory.h>
#include "test.h"
// ENVDIR is defined in the Makefile
......
......@@ -6,6 +6,7 @@
#include <sys/stat.h>
#include <toku_portability.h>
#include <db.h>
#include <memory.h>
#include "test.h"
const char *dbfile = ENVDIR "/" "test.db";
......@@ -35,7 +36,7 @@ db_get (DB *db, int k, int expectv, int val_flags) {
if (verbose) printf("%s:%d:%d:%s\n", __FILE__, __LINE__, r, db_strerror(r));
}
if (val.flags & (DB_DBT_MALLOC|DB_DBT_REALLOC))
free(val.data);
toku_free(val.data);
return r;
}
......
/* -*- 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>
......@@ -117,22 +117,22 @@ insert_test (void) {
memset(&testdata, 0, sizeof testdata); testdata.flags = DB_DBT_MALLOC;
r = dbp->get(dbp, null_txn, &key, &testdata, 0); CKERR(r);
r = dbtcmp(&data, &testdata); CKERR(r);
if (testdata.data) free(testdata.data);
if (testdata.data) toku_free(testdata.data);
/* Try to get it from secondary. */
memset(&testdata, 0, sizeof testdata); testdata.flags = DB_DBT_MALLOC;
r = sdbp->get(sdbp, null_txn, &skey, &testdata, 0); CKERR(r);
r = dbtcmp(&data, &testdata); CKERR(r);
if (testdata.data) free(testdata.data);
if (testdata.data) toku_free(testdata.data);
/* Try to pget from secondary */
memset(&testkey, 0, sizeof testkey); testkey.flags = DB_DBT_MALLOC;
memset(&testdata, 0, sizeof testdata); testdata.flags = DB_DBT_MALLOC;
r = sdbp->pget(sdbp, null_txn, &skey, &testkey, &testdata, 0); CKERR(r);
r = dbtcmp(&data, &testdata); CKERR(r);
if (testdata.data) free(testdata.data);
if (testdata.data) toku_free(testdata.data);
r = dbtcmp(&testkey, &key); CKERR(r);
if (testkey.data) free(testkey.data);
if (testkey.data) toku_free(testkey.data);
/* Make sure we fail 'pget' from primary */
r = dbp->pget(dbp, null_txn, &key, &testkey, &data, 0); assert(r == EINVAL);
......@@ -183,14 +183,14 @@ verify_gone (void) {
/* Try (fail) to get it from primary. */
data.flags = DB_DBT_MALLOC;
r = dbp->get(dbp, null_txn, &key, &data, 0); assert(r == DB_NOTFOUND);
if (data.data) free(data.data);
if (data.data) toku_free(data.data);
/* Try (fail) to get it from secondary. */
setup_student(&s); memset(&data, 0, sizeof data); data.data = &s; data.size = sizeof s;
r = getname(sdbp, NULL, &data, &skey); CKERR(r);
memset(&data, 0, sizeof data); data.flags = DB_DBT_MALLOC;
r = sdbp->get(sdbp, null_txn, &skey, &data, 0); assert(r == DB_NOTFOUND);
if (data.data) free(data.data);
if (data.data) toku_free(data.data);
/* Try (fail) to pget from secondary */
setup_student(&s); memset(&data, 0, sizeof data); data.data = &s; data.size = sizeof s;
......@@ -198,8 +198,8 @@ verify_gone (void) {
memset(&data, 0, sizeof data); data.flags = DB_DBT_MALLOC;
memset(&key, 0, sizeof key); key.flags = DB_DBT_MALLOC;
r = sdbp->pget(sdbp, null_txn, &skey, &key, &data, 0);assert(r == DB_NOTFOUND);
if (data.data) free(data.data);
if (key.data) free(key.data);
if (data.data) toku_free(data.data);
if (key.data) toku_free(key.data);
}
int
......
......@@ -2,7 +2,7 @@
#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>
......
......@@ -2,7 +2,7 @@
#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>
......
......@@ -2,7 +2,7 @@
#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>
......
......@@ -2,7 +2,7 @@
#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>
......
......@@ -3,7 +3,7 @@
#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>
......
......@@ -3,7 +3,7 @@
#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>
......
......@@ -3,7 +3,7 @@
#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>
......
......@@ -3,7 +3,7 @@
#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>
......
......@@ -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>
......
......@@ -2,7 +2,7 @@
#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>
......
......@@ -2,7 +2,7 @@
#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>
......
......@@ -2,7 +2,7 @@
#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>
......
......@@ -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>
......@@ -77,7 +77,7 @@ test_txn_recover3 (int nrows) {
if (names) {
for (i=0; names[i]; i++)
printf("%d:%s\n", i, names[i]);
free(names);
toku_free(names);
}
r = env->close(env, 0); 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>
......@@ -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 *
......
......@@ -7,7 +7,7 @@
#include <toku_portability.h>
#include <db.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <sys/stat.h>
#include "test.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>
......@@ -36,8 +36,8 @@ walk (DB *db) {
assert(i != 0);
r = cursor->c_close(cursor); 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);
}
static void
......@@ -79,7 +79,7 @@ test_insert_zero_length (int n, int dup_mode, const char *dbname) {
r = db->get(db, null_txn, &key, dbt_init_malloc(&val), 0);
assert(r == 0 && val.data != 0 && val.size == 0);
free(val.data);
toku_free(val.data);
memset(&key, 0, sizeof key);
memset(&val, 0, sizeof val);
......@@ -88,7 +88,7 @@ test_insert_zero_length (int n, int dup_mode, const char *dbname) {
r = db->get(db, null_txn, &key, dbt_init_malloc(&val), 0);
assert(r == 0 && val.data != 0 && val.size == 0);
free(val.data);
toku_free(val.data);
}
}
......
......@@ -416,7 +416,7 @@ static int do_recovery (DB_ENV *env) {
if (env->i->lg_dir) {
logdir = construct_full_name(env->i->dir, env->i->lg_dir);
} else {
logdir = strdup(env->i->dir);
logdir = toku_strdup(env->i->dir);
}
#if 0
......@@ -1302,7 +1302,7 @@ static int verify_secondary_key(DB *secondary, DBT *pkey, DBT *data, DBT *skey)
clean_up:
if (idx.flags & DB_DBT_APPMALLOC) {
/* This should be free because idx.data is allocated by the user */
free(idx.data);
toku_free(idx.data);
}
return r;
}
......@@ -2342,7 +2342,7 @@ static int do_associated_deletes(DB_TXN *txn, DBT *key, DBT *data, DB *secondary
clean_up:
if (idx.flags & DB_DBT_APPMALLOC) {
/* This should be free because idx.data is allocated by the user */
free(idx.data);
toku_free(idx.data);
}
if (r!=0) return r;
return r2;
......@@ -3073,7 +3073,7 @@ static int do_associated_inserts (DB_TXN *txn, DBT *key, DBT *data, DB *secondar
clean_up:
if (idx.flags & DB_DBT_APPMALLOC) {
/* This should be free because idx.data is allocated by the user */
free(idx.data);
toku_free(idx.data);
}
return r;
}
......
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