Hi guys, im trying to make a Dynamic Mutli dimensional Array,

There are lots of tutorials for making these (using a pointer array of poniters) but not for adding and retriving from them really.

and im having trouble retriving and adding iformation to the array,

Ill post my code for adding, creating and resizing the array, and getting information

Code:

#define oops(s) { perror((s)); exit(EXIT_FAILURE); }
#define MALLOC(s,t) if(((s) = malloc(t)) == NULL) { oops("error: malloc() "); }

double **dynarray;
int dynArraySize = 0;
int currentRow = -1;
const int COLUMS = 2;
const int INCREMENT = 10;

void createDynarray(double **arrayPtr)
{
	int i;

	MALLOC(arrayPtr, sizeof(double *) * (INCREMENT));
	for (i = 0; i < INCREMENT; i++)
	{
	    MALLOC(arrayPtr[i], sizeof(double) * COLUMS);
	}
	dynArraySize = 10;
}
void resizeDynarray(double **arrayPtr)
{
	double **tmp;
	int i;
	  if (currentRow >= dynArraySize)
	  {
	    if(tmp = realloc(arrayPtr, sizeof(double *) * (dynArraySize + (INCREMENT))) == NULL)
	    {
	      oops("realloc() error! ");
	    }
	    for(i = dynArraySize; i < (dynArraySize + INCREMENT); i++)
	    {
	      MALLOC(tmp[i], sizeof(double) * COLUMS);
	    }
	    dynArraySize += INCREMENT;
	    arrayPtr = tmp;
	  }
}

void addDoubleToArray(double **arrayPtr,double *data)
{
	int i;
	double **tmpPtr;

	currentRow++;
	if(currentRow < dynArraySize)
	{
                   arrayPtr += currentRow;
	   arrayPtr = data;
	}
	else
	{
		resizeDynarray(arrayPtr);
		addDoubleToArray(arrayPtr,data);
	}
}
double *getDoubleFromArray(double **arrayPtr,int index)
{
	double *retVal;
	if(index <= dynArraySize)
	{
		arrayPtr += index;
		retVal = arrayPtr;
	}
	else
	{
	 oops("Array out of bounds error! ");
	}
	return retVal;
}

I get a program crash when ever i try to retrive something from the array (when i call getDoubleFromArray)

its probly sometihing simple but im stumped? anyone see the problem? (i havent really dealt to much with pointers to pointers so i could be doing something very wrong i guess heh)