Commit 529339d3 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Make all external symbols in primes.o start with toku_. Addresses #8

git-svn-id: file:///svn/tokudb@678 c7de825b-a66e-492c-adef-691d508d4ae1
parent fd2e07c9
......@@ -70,7 +70,7 @@ int toku_create_cachetable(CACHETABLE *result, long size_limit, LSN initial_lsn,
int i;
t->n_in_table = 0;
t->primeidx = 0;
t->table_size = get_prime(t->primeidx);
t->table_size = toku_get_prime(t->primeidx);
MALLOC_N(t->table_size, t->table);
assert(t->table);
t->head = t->tail = 0;
......@@ -207,7 +207,7 @@ static void cachetable_rehash (CACHETABLE t, int primeindexdelta) {
int newprimeindex = primeindexdelta+t->primeidx;
if (newprimeindex < 0)
return;
int newtable_size = get_prime(newprimeindex);
int newtable_size = toku_get_prime(newprimeindex);
PAIR *newtable = toku_calloc(newtable_size, sizeof(*t->table));
int i;
//printf("%s:%d newtable_size=%d\n", __FILE__, __LINE__, newtable_size);
......
......@@ -58,7 +58,7 @@ int toku_hashtable_create (HASHTABLE *h) {
if (tab==0) return -1;
tab->n_keys=0;
tab->primeidx=0;
tab->arraysize=get_prime(tab->primeidx);
tab->arraysize=toku_get_prime(tab->primeidx);
assert(sizeof(*tab->array)==sizeof(void*));
tab->array = toku_calloc(tab->arraysize, sizeof(*tab->array));
for (i=0; i<tab->arraysize; i++) tab->array[i]=0;
......@@ -125,7 +125,7 @@ int toku_hash_find (HASHTABLE tab, bytevec key, ITEMLEN keylen, bytevec *data, I
int toku_hash_rehash_everything (HASHTABLE tab, unsigned int primeindexdelta) {
int newprimeindex = primeindexdelta+tab->primeidx;
assert(newprimeindex>=0);
unsigned int newarraysize = get_prime(newprimeindex);
unsigned int newarraysize = toku_get_prime(newprimeindex);
HASHDUP *newarray = toku_calloc(newarraysize, sizeof(*tab->array));
unsigned int i;
//printf("%s:%d newarraysize=%d\n", __FILE__, __LINE__, newarraysize);
......
......@@ -250,7 +250,7 @@ void test_insert_dup(int n, int do_delete_all) {
}
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
test_primes();
toku_test_primes();
test0();
test1();
test_insert_nodup(1000);
......
#include <assert.h>
int is_prime (int n) {
static int is_prime (int n) {
int i;
if (n==2) return 1;
if (n%2==0) return 0;
......@@ -13,7 +13,7 @@ int is_prime (int n) {
#define N_PRIMES 30
static unsigned int primes[N_PRIMES]={0};
int get_prime (unsigned int idx) {
int toku_get_prime (unsigned int idx) {
if (primes[0]==0) {
int i;
for (i=0; i<N_PRIMES; i++) {
......@@ -27,12 +27,12 @@ int get_prime (unsigned int idx) {
return primes[idx];
}
void test_primes (void) {
assert(get_prime(0)==2);
assert(get_prime(1)==5);
assert(get_prime(2)==11);
assert(get_prime(3)==17);
assert(get_prime(4)==37);
assert(get_prime(5)==67);
assert(get_prime(6)==131);
void toku_test_primes (void) {
assert(toku_get_prime(0)==2);
assert(toku_get_prime(1)==5);
assert(toku_get_prime(2)==11);
assert(toku_get_prime(3)==17);
assert(toku_get_prime(4)==37);
assert(toku_get_prime(5)==67);
assert(toku_get_prime(6)==131);
}
/* Return the smallest prime >= 2^(idx+1)
* Only works for idx<30 */
int get_prime (unsigned int idx);
void test_primes(void);
int toku_get_prime (unsigned int idx);
void toku_test_primes(void);
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