Currently Slide.content is setup as a fixed length character array of 5000 characters. We'd prefer for this to be dynamic so that even if a slide exceeds 5000 characters we won't encounter a seg fault. We'd also like to small slides utilize less memory.
I believe that this can be accomplished by setting the Slide.content variable in parser.h as a character pointer char *content and then in parser.c we'd build the content with a character array of x*y size, then we'd simply point the Slide.content variable to the character array. We may also need to allocate the character array to heap memory instead of the stack.
I'm closing this issue as I was able to implement a much better solution that will make it much easier to add features in the future. Quick synopsis of changes below;
separated struct logic from parser. struct logic is now in slides.c and slides.h
added struct line which acts as a linked list where one line leads to the next and so on. This should make it much easier to add per-line formatting as they can just be variables added to the line struct
slide struct has variable struct line *first that points to first line, then each line will point to the next till the last line
parseTXT function properly allocates data to this new format. nextLine() is called after each line to write the buffer to a new line that'll serve as the next variable to the previous line. parseTXT will increment to the next slide variable and work from that variable's first line variable
displayLoop now conforms to this new format as well, printing each line of the slide to be shown.
after displayLoop returns, main will simply free each line and slide, and close.
Currently
Slide.content
is setup as a fixed length character array of 5000 characters. We'd prefer for this to be dynamic so that even if a slide exceeds 5000 characters we won't encounter a seg fault. We'd also like to small slides utilize less memory.I believe that this can be accomplished by setting the
Slide.content
variable inparser.h
as a character pointerchar *content
and then inparser.c
we'd build the content with a character array of x*y size, then we'd simply point theSlide.content
variable to the character array. We may also need to allocate the character array to heap memory instead of the stack.