I'm declaring an array within a struct in objective C as follows
struct myStruct {
int array[size];
};
and another one
struct myStruct2 {
double array[size][size];
};
I banged my head against the wall for a while with an EXC_BAD_ACCESS code=1 error then started playing with my size. Turns out 1022 is fine (1023 elements) but 1023 (1024 elements) and up kicks out the error.
Why? Is there a way around this? It can't be a coincidence that
2^10
is crapping out on me.
I'd really like to go up to about 2^14 at least.
Something else that is strange. In xcode when I hover over my variable "size" it shows 1457743029 even though it is defined,
const int size = 1022;
What is that?
edit: I have updated my code from declarations like
myStruct instanceOfStruct;
to
struct myStruct *instanceOfStruct = malloc(sizeof(struct myStruct) * size);
memset(instanceOfStruct,0,sizeof(struct myStruct) * size);
However, I am unsure whether my "size" should really be "size" or 1. I've already included array size in the struct - am I squaring the amount of memory I need here?