First of all I know there have been previous threads like this and that there's also a faq item about this.
But I am unable to apply any of those examples to my problem, simply because I haven't done this before and I dont understand the instructions I've read. Therefore I hope you can help me with this specific problem.
Here's my problem:
I have a LINE_COUNT defined as 10000:
And I have some structs and arrays defined that use this LINE_COUNT value:
#define LINE_COUNT 10000
Now when I increase the LINE_COUNT to say 11000 the program hangs. I figured it would have to do with memory available and came across the malloc function as a possible solution for this.
char buf[BUFSIZ], id_file, id_file_array[LINE_COUNT], id_array[LINE_COUNT];
struct CAN_line linenr[LINE_COUNT];
My question is, how should I use malloc in this situation?
Do I request memory for every array and the struct that use this LINE_COUNT? Or maybe I can simply request an amount of space when I launch the program?
Anyway, I have tried the following line but I haven't got a clue if it's right or not and when it is I wouldn't even know how to check if it actually works...
Sorry for the noob level of this question It's just so not clear for me how this works.
q = (char *) malloc(2 * sizeof(struct CAN_line));
Any help would be greatly appreciated!