diff --git a/benchmarks/lhtableThreaded.c b/benchmarks/lhtableThreaded.c index 6cce5f6..55cb02a 100644 --- a/benchmarks/lhtableThreaded.c +++ b/benchmarks/lhtableThreaded.c @@ -5,6 +5,7 @@ #include #include #include +#include #include int entries; @@ -70,8 +71,8 @@ int main(int argc, char ** argv) { printf("thread_count = %d, #entries = %d\n", thread_count, entries); - pthread_t * threads = malloc(thread_count * sizeof(pthread_t)); - int* thread_args = malloc(thread_count * sizeof(int)); + pthread_t * threads = stasis_malloc(thread_count, pthread_t); + int* thread_args = stasis_malloc(thread_count, int); for(int i = 0; i < thread_count; i++) { thread_args[i] = i + 1; pthread_create(&(threads[i]), 0, worker, &(thread_args[i])); diff --git a/benchmarks/linearHashNTAMultiReader.c b/benchmarks/linearHashNTAMultiReader.c index a400fa7..2fff47c 100644 --- a/benchmarks/linearHashNTAMultiReader.c +++ b/benchmarks/linearHashNTAMultiReader.c @@ -83,7 +83,7 @@ int main(int argc, char** argv) { unlink("blob0_file.txt"); unlink("blob1_file.txt");*/ - pthread_t * workers = malloc(sizeof(pthread_t) * thread_count); + pthread_t * workers = stasis_malloc(thread_count, pthread_t); Tinit(); int xid = Tbegin(); @@ -109,7 +109,7 @@ int main(int argc, char** argv) { pthread_mutex_lock(&mutex); for(k = 0; k < thread_count; k++) { - int * k_copy = malloc(sizeof(int)); + int * k_copy = stasis_alloc(int); *k_copy = k ; pthread_create(&workers[k], &attr, go, k_copy); diff --git a/benchmarks/linearHashNTAThreaded.c b/benchmarks/linearHashNTAThreaded.c index f82a3c4..d5cc72f 100644 --- a/benchmarks/linearHashNTAThreaded.c +++ b/benchmarks/linearHashNTAThreaded.c @@ -131,7 +131,7 @@ int main(int argc, char** argv) { unlink("blob0_file.txt"); unlink("blob1_file.txt"); - pthread_t * workers = malloc(sizeof(pthread_t) * thread_count); + pthread_t * workers = stasis_malloc(thread_count, pthread_t); Tinit(); int xid = Tbegin(); @@ -154,7 +154,7 @@ int main(int argc, char** argv) { for(k = 0; k < thread_count; k++) { - int * k_copy = malloc(sizeof(int)); + int * k_copy = stasis_alloc(int); *k_copy = k ; pthread_create(&workers[k], &attr, go, k_copy); diff --git a/benchmarks/linearHashNTAWriteRequests.c b/benchmarks/linearHashNTAWriteRequests.c index e223991..18aefc3 100644 --- a/benchmarks/linearHashNTAWriteRequests.c +++ b/benchmarks/linearHashNTAWriteRequests.c @@ -211,7 +211,7 @@ int main(int argc, char** argv) { buckets[l] = 0; } - pthread_t * workers = malloc(sizeof(pthread_t) * thread_count); + pthread_t * workers = stasis_malloc(thread_count, pthread_t); Tinit(); int xid = Tbegin(); @@ -234,7 +234,7 @@ int main(int argc, char** argv) { for(k = 0; k < thread_count; k++) { - int * k_copy = malloc(sizeof(int)); + int * k_copy = stasis_alloc(int); *k_copy = k ; pthread_create(&workers[k], &attr, go, k_copy); diff --git a/benchmarks/lsn_bench_common.h b/benchmarks/lsn_bench_common.h index 805122f..5d322a5 100644 --- a/benchmarks/lsn_bench_common.h +++ b/benchmarks/lsn_bench_common.h @@ -4,13 +4,13 @@ #include void alloc_rids(long long num_rids, recordid ** slow, recordid ** fast) { - *slow = malloc(num_rids * sizeof(**slow)); - *fast = malloc((num_rids / 10) * sizeof(**fast)); + *slow = stasis_malloc(num_rids, recordid); + *fast = stasis_malloc(num_rids / 10, recordid); int xid = Tbegin(); - byte * old = malloc(PAGE_SIZE); - byte * new = malloc(PAGE_SIZE); + byte * old = stasis_malloc(PAGE_SIZE, byte); + byte * new = stasis_malloc(PAGE_SIZE, byte); for(long long i = 0; i < num_rids; ) { pageid_t pid = TpageAlloc(xid); @@ -55,7 +55,7 @@ typedef struct { } cached_addr; void build_cache(recordid * rids, cached_addr** cache, long long count) { - *cache = malloc (sizeof(**cache) * count); + *cache = stasis_malloc(count, cached_addr); lsn_t log_trunc = ((stasis_log_t*)stasis_log())->truncation_point(stasis_log()); for(long long i = 0; i < count; i++) { (*cache)[i].pid = rids[i].page; diff --git a/benchmarks/multicore/dirtyPages.c b/benchmarks/multicore/dirtyPages.c index b649ed3..9b9f3a9 100644 --- a/benchmarks/multicore/dirtyPages.c +++ b/benchmarks/multicore/dirtyPages.c @@ -37,7 +37,7 @@ int main(int argc, char * argv[]) { pthread_t workers[numthreads]; - p = malloc(sizeof(Page *) * numthreads); + p = stasis_malloc(numthreads, Page*); Tinit(); diff --git a/benchmarks/naiveMultiThreaded.c b/benchmarks/naiveMultiThreaded.c index dc63ea6..db00204 100644 --- a/benchmarks/naiveMultiThreaded.c +++ b/benchmarks/naiveMultiThreaded.c @@ -39,7 +39,7 @@ int main(int argc, char** argv) { unlink("blob0_file.txt"); unlink("blob1_file.txt"); - pthread_t * workers = malloc(sizeof(pthread_t) * thread_count); + pthread_t * workers = stasis_malloc(thread_count, pthread_t); Tinit(); int xid = Tbegin(); @@ -50,7 +50,7 @@ int main(int argc, char** argv) { int k; for(k = 0; k < thread_count; k++) { - int * k_copy = malloc(sizeof(int)); + int * k_copy = stasis_alloc(int); *k_copy = k ; pthread_create(&workers[k], NULL, go, k_copy); diff --git a/benchmarks/rawIOPS.c b/benchmarks/rawIOPS.c index 0a1936c..78b7d35 100644 --- a/benchmarks/rawIOPS.c +++ b/benchmarks/rawIOPS.c @@ -116,8 +116,8 @@ int main(int argc, char * argv[]) { } struct timeval start, stop; pthread_t status; - pthread_t * threads = malloc(sizeof(threads[0]) * num_threads); - thread_arg * arg = malloc(sizeof(arg[0]) * num_threads); + pthread_t * threads = stasis_malloc(num_threads, pthread_t); + thread_arg * arg = stasis_malloc(num_threads, thread_arg); gettimeofday(&start,0); pthread_create(&status, 0, status_worker, 0); diff --git a/benchmarks/redBlackMemoryOverhead.c b/benchmarks/redBlackMemoryOverhead.c index b8f5145..0f42714 100644 --- a/benchmarks/redBlackMemoryOverhead.c +++ b/benchmarks/redBlackMemoryOverhead.c @@ -46,10 +46,10 @@ int main(int argc, char * argv[]) { if(tree_count < tuple_count) { // printf("a1000"); // for(int i = 0; i < 1000; i++) { - entry * e = malloc(sizeof(*e)); + entry * e = stasis_alloc(entry); e->key = ((uint64_t)random()) * (uint64_t)random(); int sz = random() % (2 * tuple_size - sizeof(e)); - e->value = malloc(sz); + e->value = stasis_malloc(sz, unsigned char); for(int j = 0; j < (sz); j++) { e->value[j] = (unsigned char) (j & 255); } diff --git a/benchmarks/rose.cpp b/benchmarks/rose.cpp index 3ab0c2a..15e4c7e 100644 --- a/benchmarks/rose.cpp +++ b/benchmarks/rose.cpp @@ -79,7 +79,7 @@ pageid_t roseFastAlloc(int xid, void * conf) { static pthread_once_t alloc_key_once; static void alloc_setup(void) { pthread_once(&alloc_key_once,alloc_key_create); - pthread_setspecific(alloc_key,malloc(sizeof(alloc_struct))); + pthread_setspecific(alloc_key,stasis_alloc(alloc_struct)); } */ #define INT_CMP 1 @@ -732,8 +732,7 @@ int main(int argc, char **argv) { for(int col = 0; col < column_count; col++) { current = 0; - dataset[col] - = reinterpret_cast(malloc(sizeof(val_t) * inserts)); + dataset[col] = stasis_malloc(inserts, val_t); for (unsigned int i = 0; i < inserts; i++) { if (bump_prob == 1) { current++; @@ -757,11 +756,10 @@ int main(int argc, char **argv) { max_col_number = max_col_number < column[col] ? column[col] : max_col_number; - dataset[col] = reinterpret_cast(malloc(sizeof(val_t))); + dataset[col] = stasis_alloc(val_t); } max_col_number++; - char **toks = reinterpret_cast - (malloc(sizeof(char *) * max_col_number)); + char **toks = stasis_malloc(max_col_number, char*); printf("Reading from file %s ", file); @@ -769,7 +767,7 @@ int main(int argc, char **argv) { size_t line_len = 100; // getline wants malloced memory (it probably calls realloc...) - char * line = reinterpret_cast(malloc(sizeof(char) * line_len)); + char * line = stasis_malloc(line_len, char); FILE * input = fopen(file, "r"); if (!input) { diff --git a/benchmarks/roseTable.cpp b/benchmarks/roseTable.cpp index 1fc0b50..0729d8b 100644 --- a/benchmarks/roseTable.cpp +++ b/benchmarks/roseTable.cpp @@ -25,7 +25,7 @@ int main(int argc, char **argv) { int ret; // multicolumn is deprecated; want static dispatch! - rose::plugin_id_t * plugins = (rose::plugin_id_t*)malloc(10 * sizeof(rose::plugin_id_t)); + rose::plugin_id_t * plugins = stasis_malloc(10, rose::plugin_id_t); plugins[0] = rose::plugin_id, Rle, typ0>(); plugins[1] = rose::plugin_id, Nop, typ1>(); // rle diff --git a/benchmarks/roseTable.h b/benchmarks/roseTable.h index 744f499..a3f529f 100644 --- a/benchmarks/roseTable.h +++ b/benchmarks/roseTable.h @@ -143,12 +143,12 @@ namespace rose { max_col_number = max_col_number < column[col] ? column[col] : max_col_number; } - char ** toks = (char**)malloc(sizeof(char*)*(max_col_number+1)); + char ** toks = stasis_malloc(max_col_number+1, char*); printf("Reading from file %s\n", file); int inserts = 0; size_t line_len = 100; // getline wants malloced memmory (it probably calls realloc...) - char * line = (char*) malloc(sizeof(char) * line_len); + char * line = stasis_malloc(line_len, char); FILE * input = fopen(file, "r"); if(!input) { diff --git a/benchmarks/roseTableTpcCH-workload1.cpp b/benchmarks/roseTableTpcCH-workload1.cpp index 900e5ad..34c93ff 100644 --- a/benchmarks/roseTableTpcCH-workload1.cpp +++ b/benchmarks/roseTableTpcCH-workload1.cpp @@ -62,7 +62,7 @@ int main(int argc, char **argv) { int ret; // multicolumn is deprecated; want static dispatch! /* - rose::plugin_id_t * plugins = (rose::plugin_id_t*)malloc(COLS * sizeof(rose::plugin_id_t)); + rose::plugin_id_t * plugins = stasis_malloc(COLS, rose::plugin_id_t); // todo try Rle / For plugins[0] = rose::plugin_id, Rle, typ0>(); diff --git a/benchmarks/roseTableTpcCH-workload2.cpp b/benchmarks/roseTableTpcCH-workload2.cpp index 8d0aee7..e0c7a3d 100644 --- a/benchmarks/roseTableTpcCH-workload2.cpp +++ b/benchmarks/roseTableTpcCH-workload2.cpp @@ -37,7 +37,7 @@ int main(int argc, char **argv) { int ret; // multicolumn is deprecated; want static dispatch! - rose::plugin_id_t * plugins = (rose::plugin_id_t*)malloc(20 * sizeof(rose::plugin_id_t)); + rose::plugin_id_t * plugins = stasis_malloc(20, rose::plugin_id_t); plugins[0] = rose::plugin_id, Rle, typ0>(); plugins[1] = rose::plugin_id, Rle, typ1>(); // rle diff --git a/benchmarks/roseTableTpcCH.h b/benchmarks/roseTableTpcCH.h index 42b5ef8..99707ee 100644 --- a/benchmarks/roseTableTpcCH.h +++ b/benchmarks/roseTableTpcCH.h @@ -108,13 +108,13 @@ namespace rose { max_col_number = max_col_number < column[col] ? column[col] : max_col_number; } - char ** toks = (char**)malloc(sizeof(char*)*(max_col_number+1)); + char ** toks = stasis_malloc(max_col_number+1, char*); char * mode; printf("Reading from file %s\n", file); int inserts = 0; size_t line_len = 100; // getline wants malloced memmory (it probably calls realloc...) - char * line = (char*) malloc(sizeof(char) * line_len); + char * line = stasis_malloc(line_len, char); FILE * input = fopen(file, "r"); if(!input) { diff --git a/benchmarks/transitiveClosure.c b/benchmarks/transitiveClosure.c index 504af00..8dea579 100644 --- a/benchmarks/transitiveClosure.c +++ b/benchmarks/transitiveClosure.c @@ -191,7 +191,7 @@ int main(int argc, char ** argv) { TarrayListExtend(xid, rid, NUM_NODES); - int * node = malloc(sizeof(int) * (OUTDEGREE+1)); // the last long in the node holds flags. + int * node = stasis_malloc(OUTDEGREE+1, int); // the last long in the node holds flags. int i, j; for(i = 0; i < NUM_NODES; i++) { node[OUTDEGREE] = 0; @@ -264,10 +264,10 @@ int main(int argc, char ** argv) { Tconsumer_push(xid, globalFifo->consumer, NULL, 0, (byte*)&rid, sizeof(recordid)); numOut = 1; - pthread_t * workers = malloc(sizeof(pthread_t) * NUM_THREADS); + pthread_t * workers = stasis_malloc(NUM_THREADS, pthread_t); int j; - worker_arg * arg = malloc(sizeof(worker_arg)); + worker_arg * arg = stasis_alloc(worker_arg); // arg->dirty = dirtyFifo; arg->global = globalFifo; arg->pool = pool; diff --git a/benchmarks/turbine.c b/benchmarks/turbine.c index c4d3828..bfe9143 100644 --- a/benchmarks/turbine.c +++ b/benchmarks/turbine.c @@ -85,8 +85,8 @@ int main(int argc, char * argv[]) { int NUM_WORKERS = atoi(argv[2]); uint64_t ops = atoll(argv[3]); int write_size = atoi(argv[4]); - worker * workers = malloc(sizeof(worker) * NUM_WORKERS); - pthread_t* threads = malloc(sizeof(pthread_t) * NUM_WORKERS); + worker * workers = stasis_malloc(NUM_WORKERS, worker); + pthread_t* threads = stasis_malloc(NUM_WORKERS, pthread_t); uint64_t stride = atoll(argv[5]); int fd = -1; if(!many_handles) { diff --git a/lang/java/org_stasis_Stasis.c b/lang/java/org_stasis_Stasis.c index c56a2e2..36e7d7f 100644 --- a/lang/java/org_stasis_Stasis.c +++ b/lang/java/org_stasis_Stasis.c @@ -24,7 +24,7 @@ static byte * bytes_jbyteArray(JNIEnv *e, jbyteArray jba, size_t * sz) { *sz = (*e)->GetArrayLength(e, jba) * sizeof(byte); if((*e)->ExceptionOccurred(e)) return 0; assert(sizeof(jbyte) == 1); - jbyte * ret = malloc(*sz); + jbyte * ret = stasis_malloc(*sz, jbyte); (*e)->GetByteArrayRegion(e, jba, 0, *sz, (jbyte*)ret); if((*e)->ExceptionOccurred(e)) return 0; return (byte*)ret; diff --git a/libdfa/smash.h b/libdfa/smash.h index c0b3e9b..74785e8 100644 --- a/libdfa/smash.h +++ b/libdfa/smash.h @@ -63,8 +63,8 @@ typedef struct { /** Usage: - rb = malloc (sizeof(MonoTree)); - rb->buffer = malloc(sizeof(StateMachine) * rb_size); + rb = stasis_alloc(MonoTree); + rb->buffer = stasis_malloc(rb_size, StateMachine); init_MonoTree(rb, rb_size); diff --git a/src/libdfa/monotree.h b/src/libdfa/monotree.h index b06ccc6..fd0574f 100644 --- a/src/libdfa/monotree.h +++ b/src/libdfa/monotree.h @@ -73,8 +73,8 @@ typedef struct monoTree { /** Usage: - rb = malloc (sizeof(MonoTree)); - rb->buffer = malloc(sizeof(StateMachine) * rb_size); + rb = stasis_alloc (MonoTree); + rb->buffer = stasis_malloc(rb_size, StateMachine); init_MonoTree(rb, rb_size); diff --git a/src/stasis/operations/prepare.c b/src/stasis/operations/prepare.c index b2fac8f..66cf1ed 100644 --- a/src/stasis/operations/prepare.c +++ b/src/stasis/operations/prepare.c @@ -80,7 +80,7 @@ typedef struct{ } PrepareGuardState; void * getPrepareGuardState() { - PrepareGuardState * s = malloc (sizeof(PrepareGuardState)); + PrepareGuardState * s = stasis_alloc(PrepareGuardState); s->continueIterating = 1; s->prevLSN = -1; s->xid = -1; diff --git a/src/stasis/operations/set.c b/src/stasis/operations/set.c index 5696876..4ce10f6 100644 --- a/src/stasis/operations/set.c +++ b/src/stasis/operations/set.c @@ -194,7 +194,7 @@ static int op_set_range_inverse(const LogEntry* e, Page* p) { void TsetRange(int xid, recordid rid, int offset, int length, const void * dat) { Page * p = loadPage(xid, rid.page); - /// XXX rewrite without malloc (use read_begin, read_done) + /// XXX rewrite without stasis_malloc (use read_begin, read_done) set_range_t * range = stasis_malloc(2 * length, set_range_t); range->offset = offset; diff --git a/src/stasis/util/rw.c b/src/stasis/util/rw.c index acf0b64..ba9bbbe 100644 --- a/src/stasis/util/rw.c +++ b/src/stasis/util/rw.c @@ -10,16 +10,14 @@ rwl *initlock (void) { rwl *lock; - lock = (rwl *)malloc (sizeof (rwl)); + lock = stasis_alloc (rwl); if (lock == NULL) return (NULL); - lock->mut = (pthread_mutex_t *) malloc (sizeof (pthread_mutex_t)); + lock->mut = stasis_alloc (pthread_mutex_t); if (lock->mut == NULL) { free (lock); return (NULL); } - lock->writeOK = - (pthread_cond_t *) malloc (sizeof (pthread_cond_t)); + lock->writeOK = stasis_alloc (pthread_cond_t); if (lock->writeOK == NULL) { free (lock->mut); free (lock); return (NULL); } - lock->readOK = - (pthread_cond_t *) malloc (sizeof (pthread_cond_t)); + lock->readOK = stasis_alloc (pthread_cond_t); if (lock->writeOK == NULL) { free (lock->mut); free (lock->writeOK); free (lock); return (NULL); } diff --git a/test/2pc/always_commit.c b/test/2pc/always_commit.c index e36902d..ec7e486 100644 --- a/test/2pc/always_commit.c +++ b/test/2pc/always_commit.c @@ -86,7 +86,7 @@ int main (int argc, char ** argv) { broadcast_lists[0] = star_nodes; broadcast_lists[1] = point_nodes; - app_state = malloc(sizeof(TwoPCAppState)); + app_state = stasis_alloc(TwoPCAppState); if (!strcmp(argv[1], "c")) { assert(argc == 2); @@ -107,8 +107,8 @@ int main (int argc, char ** argv) { broadcast_lists_count, broadcast_list_host_count); localhost = broadcast_lists[1][replica]; }else { - Message * m = malloc (sizeof (Message)); - NetworkSetup * ns = malloc(sizeof(NetworkSetup)); + Message * m = stasis_alloc(Message); + NetworkSetup * ns = stasis_alloc(NetworkSetup); init_network_broadcast(ns, 12345, "127.0.0.1:12345", broadcast_lists, broadcast_lists_count, broadcast_list_host_count); m->to_machine_id = atoi(argv[2]); diff --git a/test/check_impl.h b/test/check_impl.h index 63a7a77..fe9426e 100644 --- a/test/check_impl.h +++ b/test/check_impl.h @@ -68,7 +68,7 @@ typedef struct { } SRunner; static TCase* tcase_create(const char * ignored) { - TCase* tc = malloc(sizeof(*tc)); + TCase* tc = stasis_alloc(TCase); tc->count = 0; tc->names = 0; tc->tests = 0; @@ -101,7 +101,7 @@ static void tcase_free(TCase * tc) { } static Suite * suite_create(const char * name) { - Suite* ret = malloc(sizeof(*ret)); + Suite* ret = stasis_alloc(Suite); ret->name = strdup(name); ret->tc = 0; return ret; @@ -116,7 +116,7 @@ static void suite_free(Suite* s) { free(s); } static SRunner * srunner_create(Suite* s) { - SRunner * ret = malloc(sizeof(SRunner)); + SRunner * ret = stasis_alloc(SRunner); ret->s = s; return ret; } diff --git a/test/dfa/fork_bomb.c b/test/dfa/fork_bomb.c index 9657cbb..beb56a3 100644 --- a/test/dfa/fork_bomb.c +++ b/test/dfa/fork_bomb.c @@ -78,9 +78,9 @@ int main (int argc, char** argv) { DfaSet * dfaSet = calloc(1, sizeof(DfaSet)); /* callback_fcn* callbacks[MAX_MESSAGE_COUNT]; */ - Transition * transitions = malloc (sizeof(Transition) * 3); + Transition * transitions = stasis_malloc(3, Transition); - State * states = malloc(sizeof(State) * MAX_STATE_COUNT); + State * states = stasis_malloc(MAX_STATE_COUNT, State); /* StateMachine initial_sm1_stack; */ StateMachine * initial_sm1; int transition_count; diff --git a/test/dfa/ping_pong_dfa.c b/test/dfa/ping_pong_dfa.c index a664138..773471b 100644 --- a/test/dfa/ping_pong_dfa.c +++ b/test/dfa/ping_pong_dfa.c @@ -71,9 +71,9 @@ START_TEST (pingpong_check) { DfaSet * dfaSet = calloc(1, sizeof(DfaSet)); /* callback_fcn* callbacks[MAX_MESSAGE_COUNT]; */ - Transition * transitions = malloc (sizeof(Transition) * 4); + Transition * transitions = stasis_malloc(4, Transition); - State * states = malloc(sizeof(State) * MAX_STATE_COUNT); + State * states = stasis_malloc(MAX_STATE_COUNT, State); StateMachine * initial_sm1; StateMachine * initial_sm2; int i; diff --git a/test/monotree/soundness.c b/test/monotree/soundness.c index 68b5cdd..e199dc1 100644 --- a/test/monotree/soundness.c +++ b/test/monotree/soundness.c @@ -61,8 +61,8 @@ int main () { unsigned int new_seed = (int) ((1.0* INT_MAX*rand())/(RAND_MAX+1.0)); state_machine_id remaining_xact = 0; state_machine_id last_xact = 0; - rb = malloc (sizeof(MonoTree)); - rb->buffer = malloc(sizeof(StateMachine) * rb_size); + rb = stasis_alloc(MonoTree); + rb->buffer = stasis_malloc(rb_size, StateMachine); init_MonoTree(rb, rb_size); diff --git a/test/stasis/check_allocationPolicy.c b/test/stasis/check_allocationPolicy.c index 5a43358..44af761 100644 --- a/test/stasis/check_allocationPolicy.c +++ b/test/stasis/check_allocationPolicy.c @@ -204,10 +204,10 @@ START_TEST(allocationPolicy_randomTest) { printf("\nSeed = %ld\n", seed); srandom(seed); - pageid_t * pages1 = malloc(AVAILABLE_PAGE_COUNT_A * sizeof(pageid_t)); - pageid_t * pages2 = malloc(AVAILABLE_PAGE_COUNT_B * sizeof(pageid_t)); + pageid_t * pages1 = stasis_malloc(AVAILABLE_PAGE_COUNT_A, pageid_t); + pageid_t * pages2 = stasis_malloc(AVAILABLE_PAGE_COUNT_B, pageid_t); - int * xids = malloc(sizeof(int) * XACT_COUNT); + int * xids = stasis_malloc(XACT_COUNT, int); for(int i = 0; i < XACT_COUNT; i++) { xids[i] = -1; diff --git a/test/stasis/check_blobRecovery.c b/test/stasis/check_blobRecovery.c index 8dc4970..72e4154 100644 --- a/test/stasis/check_blobRecovery.c +++ b/test/stasis/check_blobRecovery.c @@ -82,7 +82,7 @@ static byte * gen_blob(int i) { START_TEST(recoverBlob__randomized) { static uint16_t buf[4096*4/sizeof(uint16_t)]; - recordid * blobs = malloc(sizeof(recordid) * NUM_BLOBS); + recordid * blobs = stasis_malloc(NUM_BLOBS, recordid); for(int i = 0; i < NUM_BLOBS; i++) { blobs[i].size = -1; diff --git a/test/stasis/check_bloomFilter.c b/test/stasis/check_bloomFilter.c index c59ca41..29d5643 100644 --- a/test/stasis/check_bloomFilter.c +++ b/test/stasis/check_bloomFilter.c @@ -52,7 +52,7 @@ static char * malloc_random_string(int group) { char * str = 0; int strlen = 0; while(!strlen) strlen = 128 + (rand() & 127); - str = (char*)malloc(strlen + 1); + str = stasis_malloc(strlen + 1, char); str[0] = group; for(int i = 1; i < strlen; i++) { @@ -67,7 +67,7 @@ int main(int argc, char * argv[]) { (void)hash_a_fnv; (void)hash_b_fnv; const int num_inserts = 1000000; - char ** strings = (char**)malloc(num_inserts * sizeof(char*)); + char ** strings = stasis_malloc(num_inserts, char*); uint64_t sum_strlen = 0; struct timeval start, stop; gettimeofday(&start, 0); diff --git a/test/stasis/check_bufferManager.c b/test/stasis/check_bufferManager.c index c0d848a..e43180f 100644 --- a/test/stasis/check_bufferManager.c +++ b/test/stasis/check_bufferManager.c @@ -109,7 +109,7 @@ void * workerThreadWriting(void * q) { int offset = *(int*)q; recordid * rids; - rids = malloc(RECORDS_PER_THREAD * sizeof(recordid)); + rids = stasis_malloc(RECORDS_PER_THREAD, recordid); int xid = Tbegin(); int num_ops = 0; @@ -257,7 +257,7 @@ START_TEST(pageThreadedWritersTest) { Tinit(); pthread_mutex_init(&ralloc_mutex, NULL); for(i = 0; i < THREAD_COUNT; i++) { - int * j = malloc(sizeof(int)); + int * j = stasis_alloc(int); *j = i; pthread_create(&workers[i], NULL, workerThreadWriting, j); } @@ -279,7 +279,7 @@ START_TEST(pageThreadedWritersTest) { void * blindRandomWorker(void * v) { // int idx = *(int*)v; /// Don't need index; want pinned pages to overlap! - pageid_t * pageids = malloc(PINNED_PAGE_COUNT * sizeof(pageid_t)); + pageid_t * pageids = stasis_malloc(PINNED_PAGE_COUNT, pageid_t); Page ** pages = calloc(PINNED_PAGE_COUNT, sizeof(Page*)); for(int i = 0; i < PINNED_PAGE_COUNT; i++) { diff --git a/test/stasis/check_concurrentHash.c b/test/stasis/check_concurrentHash.c index 0032202..6143251 100644 --- a/test/stasis/check_concurrentHash.c +++ b/test/stasis/check_concurrentHash.c @@ -125,7 +125,7 @@ START_TEST(singleThreadHashTest) { #else ht = hashtable_init((pageid_t)((double)THREAD_ENTRIES * 1.1)); #endif - pageid_t *data = malloc(sizeof(pageid_t) * THREAD_ENTRIES); + pageid_t *data = stasis_malloc(THREAD_ENTRIES, pageid_t); for(int i = 1; i <= THREAD_ENTRIES; i++) { data[i-1] = -1 * (i * NUM_THREADS); @@ -145,7 +145,7 @@ START_TEST(wraparoundHashTest) { #else ht = hashtable_init(numEntries); #endif - pageid_t *data = malloc(sizeof(pageid_t) * THREAD_ENTRIES); + pageid_t *data = stasis_malloc(THREAD_ENTRIES, pageid_t); for(int i = 1; i <= THREAD_ENTRIES; i++) { data[i-1] = -1 * (((i << power) - 6 + stasis_util_random64(13)) / 13); @@ -162,7 +162,7 @@ START_TEST(concurrentHashTest) { #endif pthread_t workers[NUM_THREADS]; for(int i = 0 ; i < NUM_THREADS; i++) { - pageid_t *data = malloc(sizeof(pageid_t) * THREAD_ENTRIES); + pageid_t *data = stasis_malloc(THREAD_ENTRIES, pageid_t); for(int j = 1; j <= THREAD_ENTRIES; j++) { data[j-1] = -1 * (i + (j * NUM_THREADS)); diff --git a/test/stasis/check_concurrentSkipList.c b/test/stasis/check_concurrentSkipList.c index 92aead9..893291b 100644 --- a/test/stasis/check_concurrentSkipList.c +++ b/test/stasis/check_concurrentSkipList.c @@ -10,7 +10,7 @@ int num_keys = 1000000; void * key_dup(intptr_t p) { - intptr_t * ret = malloc(sizeof(intptr_t)); + intptr_t * ret = stasis_alloc(intptr_t); *ret = p; return ret; } @@ -71,7 +71,7 @@ void * worker(void* p) { */ START_TEST(concurrentSkipList_smokeTest) { list = stasis_util_skiplist_init(stasis_util_skiplist_cmp, 0); - char ** const keys = malloc(sizeof(char*) * num_keys); + char ** const keys = stasis_malloc(num_keys, char*); for(int i = 0; i < num_keys; i++) { #ifdef STRINGS int err = asprintf(&keys[i], "%d", (int)stasis_util_random64(2*num_keys)); @@ -104,9 +104,9 @@ START_TEST(concurrentSkipList_smokeTest) { START_TEST(concurrentSkipList_concurrentTest) { list = stasis_util_skiplist_init(stasis_util_skiplist_cmp, 0); concurrent = 1; - char *** const keys = malloc(sizeof(char**) * num_threads); + char *** const keys = stasis_malloc(num_threads, char**); for(int j = 0; j < num_threads; j++) { - keys[j] = malloc(sizeof(char*) * num_keys); + keys[j] = stasis_malloc(num_keys, char*); for(int i = 0; i < num_keys; i++) { #ifdef STRINGS int err = asprintf(&keys[i], "%d", (int)stasis_util_random64(2*num_keys)); @@ -118,7 +118,7 @@ START_TEST(concurrentSkipList_concurrentTest) { } printf("Initted\n"); fflush(stdout); - pthread_t * threads = malloc(sizeof(pthread_t) * num_threads); + pthread_t * threads = stasis_malloc(num_threads, pthread_t); struct timeval tv; gettimeofday(&tv,0); double start = stasis_timeval_to_double(tv); diff --git a/test/stasis/check_hazard.c b/test/stasis/check_hazard.c index 773ae5a..c74b96a 100644 --- a/test/stasis/check_hazard.c +++ b/test/stasis/check_hazard.c @@ -68,8 +68,8 @@ int hazard_finalize(void*p, void* ignored) { */ START_TEST(hazard_smokeTest) { hazard_t * h = hazard_init(2, 2, 10, hazard_finalize, 0); - char * a = malloc(1); - char * b = malloc(1); + char * a = stasis_malloc(1, char); + char * b = stasis_malloc(1, char); *a = 0; *b = 1; char * ap = hazard_ref(h, 0, (hazard_ptr*)&a); @@ -113,14 +113,14 @@ void * hazard_worker(void * hp) { } START_TEST(hazard_loadTest) { hazard_t * h = hazard_init(1, 1, 2, hazard_finalize, 0); - slots = malloc(sizeof(hazard_ptr) * NUM_SLOTS); - muts = malloc(sizeof(pthread_mutex_t) * NUM_SLOTS); + slots = stasis_malloc(NUM_SLOTS, hazard_ptr); + muts = stasis_malloc(NUM_SLOTS, pthread_mutex_t); for(int i = 0; i < NUM_SLOTS; i++) { - slots[i] = (hazard_ptr) malloc(sizeof(int)); + slots[i] = (hazard_ptr) stasis_malloc(1, int); *(int*)slots[i] = i; pthread_mutex_init(&muts[i],0); } - pthread_t * threads = malloc(sizeof(pthread_t) * NUM_THREADS); + pthread_t * threads = stasis_malloc(NUM_THREADS, pthread_t); for(int i = 0; i < NUM_THREADS; i++) { pthread_create(&threads[i], 0, hazard_worker, h); } diff --git a/test/stasis/check_io.c b/test/stasis/check_io.c index 5f3ce0e..f742f06 100644 --- a/test/stasis/check_io.c +++ b/test/stasis/check_io.c @@ -94,7 +94,7 @@ typedef struct { lsn_t trunc_val; pthread_mutex_t trunc_mut = PTHREAD_MUTEX_INITIALIZER; void load_handle(thread_arg* t) { - lsn_t * offsets = malloc(t->count * sizeof(lsn_t)); + lsn_t * offsets = stasis_malloc(t->count, lsn_t); stasis_handle_t * h = t->h; @@ -201,7 +201,7 @@ void handle_sequentialtest(stasis_handle_t * h) { printf("Seed = %ld\n", seed); srandom(seed); - int * values = malloc(VALUE_COUNT * sizeof(int)); + int * values = stasis_malloc(VALUE_COUNT, int); for(int i = 0; i < VALUE_COUNT; i++) { values[i] = i; @@ -218,15 +218,15 @@ void handle_concurrencytest(stasis_handle_t * h) { printf("Running concurrency test with %d values\n", vc); fflush(stdout); - int * values = malloc(vc * sizeof(int)); + int * values = stasis_malloc(vc, int); for(int i = 0; i < vc; i++) { values[i] = i; } - thread_arg * args = malloc(THREAD_COUNT * sizeof(thread_arg)); - pthread_t * threads = malloc(THREAD_COUNT * sizeof(pthread_t)); - stasis_handle_t ** handles = malloc(THREAD_COUNT / 2 * sizeof(*handles)); + thread_arg * args = stasis_malloc(THREAD_COUNT, thread_arg); + pthread_t * threads = stasis_malloc(THREAD_COUNT, pthread_t); + stasis_handle_t ** handles = stasis_malloc(THREAD_COUNT / 2, stasis_handle_t*); int val_per_thread = vc / THREAD_COUNT; trunc_val = 0; diff --git a/test/stasis/check_iterator.c b/test/stasis/check_iterator.c index 791d270..3798739 100644 --- a/test/stasis/check_iterator.c +++ b/test/stasis/check_iterator.c @@ -74,7 +74,7 @@ static void iterator_test(int xid, keySize = Titerator_key(xid, reference_impl, &key); valSize = Titerator_value(xid, reference_impl, &valScratch); - val = malloc(valSize); + val = stasis_malloc(valSize, byte); memcpy(val, valScratch, valSize); // pblHtInsert stores values a pointers to application managed memory. pblHtInsert(hash, key, keySize, val); diff --git a/test/stasis/check_lhtable.c b/test/stasis/check_lhtable.c index 28141e3..258956c 100644 --- a/test/stasis/check_lhtable.c +++ b/test/stasis/check_lhtable.c @@ -72,7 +72,7 @@ START_TEST(lhtableTest) srand(tv.tv_sec + tv.tv_usec); */ - char** keys = malloc(NUM_ENTRIES * sizeof(char*)); + char** keys = stasis_malloc(NUM_ENTRIES, char*); struct LH_ENTRY(table) * t = LH_ENTRY(create)(100); for(long i = 0; i < NUM_ENTRIES; i++) { int keyLen = asprintf(&(keys[i]), "--> %ld <--\n", i); @@ -135,8 +135,8 @@ START_TEST(lhtableRandomized) { struct LH_ENTRY(table) * t = LH_ENTRY(create)(stasis_util_random64(10000)); int numSets = stasis_util_random64(MAXSETS); - int* setLength = malloc(numSets * sizeof(int)); - long** sets = malloc(numSets * sizeof(long*)); + int* setLength = stasis_malloc(numSets, int); + long** sets = stasis_malloc(numSets, long*); int64_t nextVal = 1; int64_t eventCount = 0; @@ -146,7 +146,7 @@ START_TEST(lhtableRandomized) { for(int i =0; i < numSets; i++) { setLength[i] = stasis_util_random64(MAXSETLEN); - sets[i] = malloc(setLength[i] * sizeof(long)); + sets[i] = stasis_malloc(setLength[i], long); eventCount += setLength[i]; for(int j =0; j < setLength[i]; j++) { sets[i][j] = nextVal; diff --git a/test/stasis/check_linearHashNTA.c b/test/stasis/check_linearHashNTA.c index d600a6c..a36da0c 100644 --- a/test/stasis/check_linearHashNTA.c +++ b/test/stasis/check_linearHashNTA.c @@ -317,7 +317,7 @@ START_TEST(linearHashNTAThreadedTest) { Tcommit(xid); pthread_t threads[NUM_THREADS]; for(i = 0; i < NUM_THREADS; i++) { - linear_hash_worker_args * args = malloc(sizeof(linear_hash_worker_args)); + linear_hash_worker_args * args = stasis_alloc(linear_hash_worker_args); args->thread = i; args->rid= rid; pthread_create(&threads[i], NULL, &worker, args); @@ -346,7 +346,7 @@ START_TEST(linearHashNTAThreadedTestRandomized) { Tcommit(xid); pthread_t threads[NUM_THREADS]; for(i = 0; i < NUM_THREADS; i++) { - linear_hash_worker_args * args = malloc(sizeof(linear_hash_worker_args)); + linear_hash_worker_args * args = stasis_alloc(linear_hash_worker_args); args->thread = i; args->rid= rid; pthread_create(&threads[i], NULL, &worker, args); diff --git a/test/stasis/check_linkedListNTA.c b/test/stasis/check_linkedListNTA.c index b970576..bd4d9b1 100644 --- a/test/stasis/check_linkedListNTA.c +++ b/test/stasis/check_linkedListNTA.c @@ -169,7 +169,7 @@ START_TEST ( linkedListMultiThreadedNTA ) { pthread_t threads[NUM_THREADS]; for(i = 0; i < NUM_THREADS; i++) { - workerarg * arg = malloc(sizeof(workerarg)); + workerarg * arg = stasis_alloc(workerarg); arg->thread = i; arg->listRoot = listRoot; pthread_create(&threads[i],NULL, &worker, arg); diff --git a/test/stasis/check_lockManager.c b/test/stasis/check_lockManager.c index 1b7babb..facd984 100644 --- a/test/stasis/check_lockManager.c +++ b/test/stasis/check_lockManager.c @@ -108,7 +108,7 @@ START_TEST(recordidLockManagerTest) { int i; printf("The following numbers are deadlock counts for each thread.\n"); for(i = 0; i < THREAD_COUNT; i++) { - int *j = malloc(sizeof(int)); + int *j = stasis_alloc(int); *j = i; pthread_create(&workers[i], NULL, ridWorkerThread, j); } @@ -127,7 +127,7 @@ START_TEST(pageLockManagerTest) { int i; printf("The following numbers are deadlock counts for each thread.\n"); for(i = 0; i < THREAD_COUNT; i++) { - int *j = malloc(sizeof(int)); + int *j = stasis_alloc(int); *j = i; pthread_create(&workers[i], NULL, pageWorkerThread, j); } diff --git a/test/stasis/check_min.c b/test/stasis/check_min.c index 0e2411b..12248ec 100644 --- a/test/stasis/check_min.c +++ b/test/stasis/check_min.c @@ -115,8 +115,8 @@ START_TEST(minRandomTest) { stasis_aggregate_min_t * b = stasis_aggregate_min_init(0); const int COUNT = 10000; - lsn_t * vals = malloc(sizeof(lsn_t) * COUNT); - lsn_t * bits = malloc(sizeof(lsn_t) * COUNT); + lsn_t * vals = stasis_malloc(COUNT, lsn_t); + lsn_t * bits = stasis_malloc(COUNT, lsn_t); for(int i = 0; i < COUNT; i++) { vals[i] = i; bits[i] = 0; diff --git a/test/stasis/check_multiplexer.c b/test/stasis/check_multiplexer.c index 02aef33..9eb8c0d 100644 --- a/test/stasis/check_multiplexer.c +++ b/test/stasis/check_multiplexer.c @@ -228,7 +228,7 @@ START_TEST(multiplexTest) { // printf("->(%d)", fifoPool->fifoCount); fflush(stdout); - pthread_t * workers = malloc(sizeof(pthread_t) * fifoPool->fifoCount); + pthread_t * workers = stasis_malloc(fifoPool->fifoCount, pthread_t); for(i = 0 ; i < fifoPool->fifoCount; i+=2) { // lladdConsumer_t * consumer = fifoPool->pool[i]->consumer; diff --git a/test/stasis/check_operations.c b/test/stasis/check_operations.c index b9b3882..e585125 100644 --- a/test/stasis/check_operations.c +++ b/test/stasis/check_operations.c @@ -358,7 +358,7 @@ START_TEST(operation_nestedTopAction) { int xid= Tbegin(); int *dat; - dat = malloc(sizeof(int)); + dat = stasis_alloc(int); recordid rid1 = Talloc(xid, sizeof(int)); recordid rid2 = Talloc(xid, sizeof(int)); recordid rid3 = Talloc(xid, sizeof(int)); @@ -574,7 +574,7 @@ START_TEST(operation_lsn_free) { Page * p = loadPage(xid,pid); stasis_page_slotted_lsn_free_initialize_page(p); // XXX hack! - byte * old = malloc(PAGE_SIZE); + byte * old = stasis_malloc(PAGE_SIZE, byte); memcpy(old, p->memAddr, PAGE_SIZE); int fortyTwo = 42; for(int i = 0; i < 100; i++) { @@ -583,7 +583,7 @@ START_TEST(operation_lsn_free) { stasis_record_write(xid, p, rid[i], (const byte*)&fortyTwo); stasis_page_lsn_write(xid, p, -1); } - byte * new = malloc(PAGE_SIZE); + byte * new = stasis_malloc(PAGE_SIZE, byte); memcpy(new, p->memAddr, PAGE_SIZE); memcpy(p->memAddr, old, PAGE_SIZE); releasePage(p); @@ -638,7 +638,7 @@ START_TEST(operation_reorderable) { Page * p = loadPage(xid,pid); stasis_page_slotted_lsn_free_initialize_page(p); // XXX hack! - byte * old = malloc(PAGE_SIZE); + byte * old = stasis_malloc(PAGE_SIZE, byte); memcpy(old, p->memAddr, PAGE_SIZE); int fortyTwo = 42; for(int i = 0; i < 100; i++) { @@ -647,7 +647,7 @@ START_TEST(operation_reorderable) { stasis_record_write(xid, p, rid[i], (const byte*)&fortyTwo); stasis_page_lsn_write(xid, p, -1); } - byte * new = malloc(PAGE_SIZE); + byte * new = stasis_malloc(PAGE_SIZE, byte); memcpy(new, p->memAddr, PAGE_SIZE); memcpy(p->memAddr, old, PAGE_SIZE); releasePage(p); diff --git a/test/stasis/check_page.c b/test/stasis/check_page.c index ce900ad..cbb200c 100644 --- a/test/stasis/check_page.c +++ b/test/stasis/check_page.c @@ -198,7 +198,7 @@ static void* latchFree_worker_thread(void * arg_ptr) { START_TEST(latchFreeThreadTest) { Tinit(); int NUM_THREADS = 200; - Page ** pages = malloc(sizeof(Page*)*NUM_THREADS); + Page ** pages = stasis_malloc(NUM_THREADS, Page*); int xid = Tbegin(); pageid_t region = TregionAlloc(xid, NUM_THREADS, -1); @@ -208,10 +208,10 @@ START_TEST(latchFreeThreadTest) { stasis_page_slotted_latch_free_initialize_page(pages[i]); } - pthread_t * threads = malloc(sizeof(pthread_t) * NUM_THREADS); + pthread_t * threads = stasis_malloc(NUM_THREADS, pthread_t); for(int i = 0; i < NUM_THREADS; i++) { - latchFree_worker_thread_args * arg = malloc(sizeof(*arg)); + latchFree_worker_thread_args * arg = stasis_alloc(latchFree_worker_thread_args); arg->pages = pages; arg->my_page = i; arg->num_pages = NUM_THREADS; diff --git a/test/stasis/check_rangeTracker.c b/test/stasis/check_rangeTracker.c index abb1b38..13f0899 100644 --- a/test/stasis/check_rangeTracker.c +++ b/test/stasis/check_rangeTracker.c @@ -294,7 +294,7 @@ START_TEST (rangeTracker_randomTest) { srandom(seed); range ** r_arry; - range * ranges = malloc(sizeof(range) * RANGE_COUNT); + range * ranges = stasis_malloc(RANGE_COUNT, range); int * pins = calloc(RANGE_COUNT, sizeof(int)); rangeTracker * rt = rangeTrackerInit(QUANTIZATION); for(long i = 0; i < RANGE_COUNT; i++) { diff --git a/test/stasis/check_redblack.c b/test/stasis/check_redblack.c index 6cbb94f..0c98292 100644 --- a/test/stasis/check_redblack.c +++ b/test/stasis/check_redblack.c @@ -92,7 +92,7 @@ START_TEST(rbRandTest) { rbtree *stl_1 = stl_rbinit(cmp_1, NULL); rbtree *stl_2 = stl_rbinit(cmp_2, NULL); - tup * entries = malloc(sizeof(tup) * NUM_ENTRIES); + tup * entries = stasis_malloc(NUM_ENTRIES, tup); #ifdef DBUG_TEST for(uint64_t i = 0; i < NUM_ENTRIES; i++) { entries[i].a = i; diff --git a/test/stasis/check_regions.c b/test/stasis/check_regions.c index 8e4badf..b9acf3a 100644 --- a/test/stasis/check_regions.c +++ b/test/stasis/check_regions.c @@ -249,7 +249,7 @@ START_TEST(regions_lockRandomizedTest) { for(int i = 0; i < NUM_XACTS; i++) { xids[i] = Tbegin(); assert(xids[i] < NUM_XACTS + FUDGE); - xidRegions[xids[i]] = malloc(sizeof(pageid_t) * NUM_OPS); + xidRegions[xids[i]] = stasis_malloc(NUM_OPS, pageid_t); xidRegionCounts[xids[i]] = 0; } int activeXacts = NUM_XACTS; diff --git a/test/stasis/check_ringbuffer.c b/test/stasis/check_ringbuffer.c index 56ce21c..18c5075 100644 --- a/test/stasis/check_ringbuffer.c +++ b/test/stasis/check_ringbuffer.c @@ -60,11 +60,11 @@ terms specified in this license. static int rb_test(double readBlock, double writeBlock) { int i; - byte ** array = malloc(sizeof(byte*) * NUM_ENTRIES); - int * length = malloc(sizeof(int) * NUM_ENTRIES); + byte ** array = stasis_malloc(NUM_ENTRIES, byte*); + int * length = stasis_malloc(NUM_ENTRIES, int); for(i = 0; i < NUM_ENTRIES; i++) { length[i] =1.0+ 1000.0 * (double)rand() / (double)RAND_MAX; - array[i] = malloc(length[i]); + array[i] = stasis_malloc(length[i], byte); int j; for(j = 0; j < length[i]; j++) { array[i][j] = i + j; @@ -108,7 +108,7 @@ static int rb_test(double readBlock, double writeBlock) { int numToRead = 1.0 + readBlock * ((double)rand() / (double)RAND_MAX); // printf("%d\n", numToRead); for(i = 0; i < numToRead; i++) { - byte * buf = malloc(length[readPos]); + byte * buf = stasis_malloc(length[readPos], byte); if(!ringBufferTruncateRead(buf, log, length[readPos])) { int j; for(j = 0; j < length[readPos]; j++) { diff --git a/test/stasis/check_transactional2.c b/test/stasis/check_transactional2.c index 9f189e0..7660dc9 100644 --- a/test/stasis/check_transactional2.c +++ b/test/stasis/check_transactional2.c @@ -75,7 +75,7 @@ int arrayCmp(int * array, int * array2) { /** Allocate a bunch of blobs, set them, read them, commit them, and read it again, chang them, abort, and read again. */ void * writingAbortingBlobWorkerThread ( void * v ) { int offset = * (int *) v; - recordid * rids = malloc(BLOBS_PER_THREAD * sizeof(recordid)); + recordid * rids = stasis_malloc(BLOBS_PER_THREAD, recordid); int xid = Tbegin(); for(int i = 0; i < BLOBS_PER_THREAD; i++) { rids[i] = Talloc(xid, 1024 * sizeof(int)); @@ -137,7 +137,7 @@ void * writingAbortingBlobWorkerThread ( void * v ) { /** Allocate a bunch of stuff, set it, read it, commit it, and read it again. */ void * writingAbortingWorkerThread ( void * v ) { int offset = * (int *) v; - recordid * rids = malloc(RECORDS_PER_THREAD * sizeof(recordid)); + recordid * rids = stasis_malloc(RECORDS_PER_THREAD, recordid); int xid = Tbegin(); for(int i = 0; i < RECORDS_PER_THREAD; i++) { rids[i] = Talloc(xid, sizeof(int)); @@ -195,7 +195,7 @@ void * writingAbortingWorkerThread ( void * v ) { /** Allocate a bunch of stuff, set it, read it, commit it, and read it again. */ void * writingWorkerThread ( void * v ) { int offset = * (int *) v; - recordid * rids = malloc(RECORDS_PER_THREAD * sizeof(recordid)); + recordid * rids = stasis_malloc(RECORDS_PER_THREAD, recordid); int xid = Tbegin(); for(int i = 0; i < RECORDS_PER_THREAD; i++) { rids[i] = Talloc(xid, sizeof(int)); @@ -471,7 +471,7 @@ START_TEST(transactional_blobs_threads_abort) { START_TEST(transactional_noop_xacts) { Tinit(); - int * xids = malloc(sizeof(xids[0]) * MAX_TRANSACTIONS); + int * xids = stasis_malloc(MAX_TRANSACTIONS, int); for(int i = 0; i < MAX_TRANSACTIONS; i++) { xids[i] = Tbegin(); } diff --git a/test/stasis/fault_injection/fisubject.c b/test/stasis/fault_injection/fisubject.c index 5263c2b..d5bad22 100644 --- a/test/stasis/fault_injection/fisubject.c +++ b/test/stasis/fault_injection/fisubject.c @@ -109,7 +109,7 @@ runSubject() { commitLog = open("commits.txt", O_CREAT | O_RDWR | O_APPEND, 0777); /* Allocate the worker threads. */ - threads = (pthread_t*) malloc(numThreads * sizeof(pthread_t)); + threads = stasis_malloc(numThreads, pthread_t); pthread_attr_init(&attr); pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN); @@ -145,7 +145,7 @@ threadFunc(void* arg_ptr) { /* Allocate the buffer that stores all outstanding hash table insertions. */ bufferTotalSize = BUFFER_INITIAL_LENGTH; bufferCurrentLength = 0; - insertBuffer = (char*) malloc(bufferTotalSize * sizeof(char)); + insertBuffer = stasis_malloc(bufferTotalSize, char); xid = Tbegin();