Addresses/scattered.c File Reference

Task to free elements from address table in random order.Allocated memory stored in the 'addr' table are free'd in random order. More...

#include <stdio.h>
#include <stdlib.h>

Functions

void fillList ()
 Required code to populate addr table with appropriate number of allocated memory pointers.
int totient (int i)
 Compute the totient(i), which in number theory is the number of times to which you can add i until you get back to zero (modulo the mask).
void prepareInput ()
 Preprocess by computing the totient of the given array.
void execute ()
 Execute by invoking malloc(numElements) a total of numT times.

Variables

int numT
 Number of instances that were allocated.
void * addr []
 The table of allocated memory.
int k
 Using number theory, identify an integer 'k' that can be used to cycle through all elements in addr by simple addition and modulo arithmetic.
int mask
 Use 32-bit mask rather than modulo for speed.


Detailed Description

Task to free elements from address table in random order.Allocated memory stored in the 'addr' table are free'd in random order.

Author:
George Heineman
Date:
6/15/08

Function Documentation

void execute (  ) 

Execute by invoking malloc(numElements) a total of numT times.

void fillList (  ) 

Required code to populate addr table with appropriate number of allocated memory pointers.

void prepareInput (  ) 

Preprocess by computing the totient of the given array.

int totient ( int  i  ) 

Compute the totient(i), which in number theory is the number of times to which you can add i until you get back to zero (modulo the mask).

Parameters:
i 
Returns:
integer representing delta value to add


Variable Documentation

void* addr[]

The table of allocated memory.

int k

Using number theory, identify an integer 'k' that can be used to cycle through all elements in addr by simple addition and modulo arithmetic.

int mask

Use 32-bit mask rather than modulo for speed.

int numT

Number of instances that were allocated.

Algorithm Development Kit 1.0