Hi,
My question is more of a perfomance or common practice doubt about dynamic structures usage:
I have a function that will be called to search a file for a certain condition in particular time windows. This function returns all the time windows that satisfy this condition.
The amount of time windows that satisfy the condition will rarely be high (suppose high is 1500), and it will normally have 1 or 2 orders of magnitude.
Considering I only need the time windows numbers, what is the best solution for the problem?
Should I pass the address to an array of int's (let's say with space for 10 int's allocated initially) and keep using realloc to increment the size, or should I create a list and malloc'ing with every new time window found? (don't know exactly why, but I'm feeling a list for just one int a bit of overkill)
Thanks in advance for any comments
My question is more of a perfomance or common practice doubt about dynamic structures usage:
I have a function that will be called to search a file for a certain condition in particular time windows. This function returns all the time windows that satisfy this condition.
The amount of time windows that satisfy the condition will rarely be high (suppose high is 1500), and it will normally have 1 or 2 orders of magnitude.
Considering I only need the time windows numbers, what is the best solution for the problem?
Should I pass the address to an array of int's (let's say with space for 10 int's allocated initially) and keep using realloc to increment the size, or should I create a list and malloc'ing with every new time window found? (don't know exactly why, but I'm feeling a list for just one int a bit of overkill)
Thanks in advance for any comments
Comment