Cotix / cReddit

CLI Reddit client written in C. Oh, crossplatform too!
Other
96 stars 14 forks source link

Fixes and formatting #14

Closed kdef closed 11 years ago

kdef commented 11 years ago

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:

postList[atPost].id = malloc(t[i].end-t[i].start+1);

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.