In main.c we create an array of posts on the stack to pass to the redditGetSubreddit function. When populating each post in the array we alloc space for the id, title, votes, author, and subreddit like so:
After using the array of posts in showSubreddit function these fields were never freed. A couple other things were never freed either and are now fixed.
Formatting changes
I added a little formatting to the showSubreddit so things are easier to read and look a little more uniform. These changes were kind of hacky and are meant to be temporary until we do some major work on the ncurses display.
Oh and I typedef'd the structs in reddit.h so we don't need to write struct everywhere.
Fixed multiple memory leaks
In main.c we create an array of posts on the stack to pass to the redditGetSubreddit function. When populating each post in the array we alloc space for the id, title, votes, author, and subreddit like so:
After using the array of posts in showSubreddit function these fields were never freed. A couple other things were never freed either and are now fixed.
Formatting changes
I added a little formatting to the showSubreddit so things are easier to read and look a little more uniform. These changes were kind of hacky and are meant to be temporary until we do some major work on the ncurses display.
Oh and I typedef'd the structs in reddit.h so we don't need to write
struct
everywhere.