My first thought here is to use a dynamic array, but I am looking for something better.
Currently I have the text files open into "chunks". Every word or group of spaces makes up a "chunk". Then I have a line number in this structure and a chunk number for ordering on a line.
typedef struct TextData {
char* chunk;
int index, line;
}TDATA;
I am not sure if this is a good idea as this could lead to allocating to much dynamic memory and is prone to memory leaks. At least to my knowledge.
What I am looking for is a better way to implement this.
This is being used for a text editor/console combination program that is going to be made into a dynamic lib for reuse in other programs/games. A small finger print is a big part of this implementation.
Text is placed into a load buffer than a undo buffer tracks only changed chunks the last buffer is a display buffer that is used by an application or interface to display the unsaved edits of the complete file.
Needs to be thread safe as well.