Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

farmerdoug

macrumors 6502a
Original poster
Sep 16, 2008
541
0
memset gives an error. What did I do wrong? When signal was *signal, I didn't get an error. As near as I can tell, I am still sending a 1-D array to find_breakouts. thanks

Code:
int  *****signal

signal = (int*****) calloc (number_of_vols, sizeof(int****));
		for (i = 0; i < number_of_vols; i++)
			{
			signal[i] = (int****) calloc (number_of_vols, sizeof(int ***));
			for (j = 0; j < number_of_vols; j++)
				{
				signal[i][j] = (int***) calloc (num_buy_channels, sizeof(int **));
				for (k = 0; k < num_buy_channels; k++)
					{
					signal[i][j][k] = (int**) calloc (num_sell_channels, sizeof(int *));
					for (l = 0; l < num_sell_channels; l++)
						signal[i][j][k][l] = (int*) calloc (days_of_data, sizeof(int ));
						
					}}}

find_breakouts(sauce, signal[vol1][vol2][buy_channel][sell_channel],buy_count, sell_count, date_list);

void find_breakouts( float* sauce,  int * sign, int buy_count, int sell_count, char ** date_list)
{

	int i, j;
	int  search, end;


	memset(sign, 0, days_of_data*sizeof(int));
 
Its a EXC_BAD_ACCESS error. A problem with memory allocation. You gave me a clue. Have to check things.
 
How much do you allocate in each dimension? You never check the return value of calloc and it's not unlikely that you ran out of memory. :D

For example, allocating 100 items of size int would give: 100^5 * 4 = 40 gigabytes.
 
I added a check and yes I wasn't running out of memory. What I was doing was over stepping the memory by using the wrong variables in for the indicies.
Thanks.
 
OK, this is not much of a useful post but I just thought it was amusing that I opened this thread, saw the first line of code with a 5-fold-nested pointer, and I immediately knew who posted this thread without seeing the name of the submitter yet.

Farmerdoug, I wonder whether the complexity of the stuff you're trying to do wouldn't warrant you investing some time in a higher-level language...
 
OK, this is not much of a useful post but I just thought it was amusing that I opened this thread, saw the first line of code with a 5-fold-nested pointer, and I immediately knew who posted this thread without seeing the name of the submitter yet.

Farmerdoug, I wonder whether the complexity of the stuff you're trying to do wouldn't warrant you investing some time in a higher-level language...

Been telling him that for years...
 
I think some typedefs are called for... So that you don't have to write ***** repeatedly (looks like I have censored profanity, hah.)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.