I hope this question won't be weighted too much on discussion but on a clear answer.
I learned C at university and just started to write my first useful program (meaning without a specification). I just stumbled upon an issue which I hadn't dealt with so far, and I think they did not mention it in the lecture:
When I allocate memory that is likely to be resized, I should not store pointers to addresses of this allocated space. Because when I reallocate, the space might be moved to a differend location, which makes every pointer to this region worthless. This brings me to the conclusion that I cannot store a linked list inside the space, with every element 'living' somewhere in this space, since reallocating might invalidate all of the 'next' and 'prev' pointers.
This is an issue I never came across, that's why I wanted to ask you if there is some solution to this. Specifically: I have a shared memory region and want to store all my data in it, so that different processes can work on it. Since the data (strings) will be added and removed frequently and must be in a specific order, I thought a linked list would be the best way to go. Now I've realized I can't do it this way. Or am I just too blind to see the obvious solution? How would you go about this? (I don't want to store the whole thing in a file, it should stay in (main)memory)
thanks and best regards, phil