Extended cli app in C - Devlog
Info
This is where I will keep track of the changes I make to the app. This is a method that works great for me to reflect on what I've done, and what I need to do, thus increasing my productivity as I don't have to think about what I need to do next as much when I sit down to work on the project again.
13.04.23 / 13th of April 2023 | Working on the notes app
- Added a changelog.md file
The current state of the notes app is that I’m able to read input from the user, add a title, write the title and contents to a file, but it pretty much ends there. I’m not able to read from the file, and I’m not able to print the contents of the file to the terminal. Issues with linked lists, and memory allocation.
The menu is working though. All things considered, using ANSI escape codes to create a menu is pretty cool.
Some wins:
Was able to read from the config-file and parse the key-value pair. I had a typo in the key in the key-value pair the program was supposed to read from it. I had note_count
instead of notes_count
..
Now that I’m able to read from the config file, other issues have emerged.
Some issues:
This is some error in the way I read the amount of bytes stored based on the amount of notes. The numbers are all over the place, which is a good indicator that I’m printing a memory address instead of the actual value.
Will take a closer look at that later.
The bigger issue is:
Corrupted double-linked list
This is a memory error, which I have no idea how to fix. I’m not sure if it’s a memory leak, or if I’m just not freeing the memory correctly. Will have to take a look at this with gdb and a fresh and clear mind tomorrow.
This happens both when I try to add a note and then list them, and when I try to list the notes without adding any.
In my config-file I have the following:
notes_count=1
because I’m just overwriting the same note every time I add a new one. This will of course be fixed later, but for now I just want to get the app to work.
Anyways, since I have a file to read from, and I have written to it already, I know the problem is in the way I read the notes from the file. Probably in the way I allocate memory somewhere.