Beispiel #1
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;
}
Beispiel #2
0
void *class_calloc(size_t nmemb, size_t size) {
  void *mem;

  mem = class_malloc(nmemb*size);
  memset(mem,0,nmemb*size);
  return mem;
}
void *thread_func(void *arg) {
    int i;
    char *strings[10];

    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();
}
Beispiel #4
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();
}
Beispiel #5
0
void *class_realloc(void *ptr, size_t size) {
  void *mem;
  size_t oldsize;

  mem=class_malloc(size);
  if (!mem)
    return NULL;

  oldsize=PTRTOMNODE(ptr)->size;
  memcpy(mem,ptr,oldsize);

  class_free(ptr);
  return mem;
}
Beispiel #6
0
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;
}
Beispiel #8
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
}