int main() { printf("Version %f.%f\n", cs224_project_VERSION_MAJOR, cs224_project_VERSION_MINOR); class_memory(mem,MSIZE); // give it memory allocator struct thread_pair threads[10]; std::vector<thread_pair> vThreads(10); void *exit_status; printf( "Thread Test begin...\n"); // main program continues while thread executes int i=1; for(i=1; i < 10; ++i) { threads[i].arg = i; pthread_create(&(threads[i].id), NULL, thread_func, &(threads[i].arg)); } // wait for the thread to terminate for(i=1; i < 10; ++i) { pthread_join(threads[i].id, &(threads[i].exit_status)); } printf("Thread test end...\n"); return 0; }
int main(int argc, char * argv[]) { double power = 1; int size = 1; double output = 0; double total = 0; if (argc != 2) { printf("Enter this size of memory to be allocated.\n"); return 0; } int mSize = atoi(argv[1]); //unsigned char mem[mSize]; unsigned char* pointer = malloc(mSize); if (pointer) { class_memory(pointer, mSize); while (class_malloc(size)) { size = (int)pow(2.0,power); power++; } } class_stats(); return 0; }
int main(int argc, char * argv[]) { int i; char *strings[10]; class_memory(mem,MSIZE); // give it memory allocator for (i = 0; i<10; i++) strings[i] = (char *)class_malloc(1024); //allocate from classmem library for (i = 9; i>=0; i--) class_free(strings[i]); class_stats(); }
int main(int argc, char * argv[]) { printf("%s Version %d.%d\n",argv[0], Cma_VERSION_MAJOR, Cma_VERSION_MINOR); printf("Usage: %s\n",argv[0]); int i; char *strings[10]; class_memory(mem,MSIZE); // give it memory allocator for (i = 0; i<10; i++) strings[i] = (char *)class_malloc(1024); //allocate from classmem library for (i = 9; i>=0; i--) class_free(strings[i]); class_stats(); }
int main(int argc, char * argv[]) { int MSIZE; MSIZE = atoi(argv[1]); char * mem; mem = malloc(MSIZE); class_memory(mem,MSIZE); // give it memory allocator int n = 1; while (mem) { mem = class_malloc(n); n *= 2; } class_free(mem); class_stats(); return 0; }
int main(int argc, char * argv[]) { int i; double *arrays[ARRAYNUM]; class_memory(mymemory,MSIZE); // give it memory allocator for (i = 0; i<ARRAYNUM; i++) arrays[i] = (double *)class_malloc(ARRAYSIZE); //allocate from classmem library for (i = 0; i<ARRAYNUM; i++) arrays[i][0] = i; for (i = 0; i<ARRAYNUM; i++) printf("%0.2d",arrays[i][0]);//print out the first element for (i = ARRAYNUM-1; i>=0; i--) class_free(arrays[i]); class_stats(); return 0; }
int main (int argc, char* argv[]) { int i; char *alph[LIMIT]; // character array to allocate class_memory(m,SIZE2); // pass char array of size SIZE2 // to class_memory for allocation for (i = 0; i<LIMIT; i++) alph[i] = (int *)class_malloc(SIZE1); // allocate using classmem lib for (i = 0; i<LIMIT; i++) { alph[i] = i%26+'a'; // set member value printf("%c", (int) alph[i]); // immediately print said value } puts("\n"); // end line for (i = LIMIT; i>0; i--) class_free(alph[i]); // release allocated memory used by alph array class_stats(); // pop stats up to see what's happened }