I'm using the TM4C1294XL board with CCS. The following code gets stuck at iteration number 255 ( i.e. when TestTempInt = 255).
Array x_frame;
InitNullArray(&x_frame);
for(TestTempInt=n;TestTempInt<=(n+499);TestTempInt++){
AddConsToArr(&x_frame,X[TestTempInt]);
printf("%d\n",TestTempInt);
}
The Array structure and Function declarations are as follows:
InitialArrayValue = -999;
typedef struct ArrayStruct{ float * array; size_t used; size_t size; }Array; // INITIALIZE NULL ARRAY void InitNullArray(Array * ArrayPtr){ ArrayPtr->array=NULL; freeArray(ArrayPtr); ArrayPtr->array = (float *)malloc(1 * sizeof(float)); ArrayPtr->used = 0; ArrayPtr->size = 1; ArrayPtr->array[0] = InitialArrayValue; } // ADD CONSTANT TO ARRAY ( A=[A;C] ) void AddConsToArr(Array * InitialArray, float NewValue){ insertArray(InitialArray,NewValue); } // INSERT ELEMENT INTO ARRAY void insertArray(Array *a, float element) { if (a->used+1 == a->size) { a->size *= 2; a->array = (float *)realloc(a->array, a->size * sizeof(float)); } a->array[(a->used)+1] = element; a->used=a->used+1; }
Is this a matter of Heap or Stack size ? If so, how much can I allocate to each ? If not, what other thing should I be looking at. Please advise. Thank you.
P.S: The Array Structure itself is made so that it mimics the array indexing used in MATLAB.