Memory Explorer banner

Memory Explorer

11 devlogs
7h 20m 39s

Memory Explorer is a C program that implements and benchmarks three data structures for storing user scores:

  • Dynamic Array
  • Linked List
  • Hash Table
This project uses AI

Used ChatGPT to review my code to make sure there’s no memory leaks

Demo Repository

Loading README...

Vulcan

Shipped this project!

Hours: 7.34
Cookies: 🍪 28
Multiplier: 3.83 cookies/hr

This is my first project in C, and I’m really proud of it, because now it can do exactly what I wanted to learn C for: memory management to create special data structures that I can manipulate myself.

The benchmark stats look great, and it’s nice to know hash tables are actually simple to implement, but also reduce operation time a lot.

Vulcan

Benchmarking is done

  • I added header files for each data structure
  • I created 783 data entries in the text file
  • MOST IMPORTANTLY I FINISHED THE BENCHMARKING LOGIC

Moral of the story: Hash Table is the best (it logically makes sense as well)

Attachment
0
Vulcan

First and Last Devlog of Hash Table

I implemented hash table from start to finish, it was very simple as it was just an array of linked lists.

  • I created the load function to load the data from the text file
  • I created the unload function to free all the memory so there are no memory leaks
  • I created the add_data function to add a data entry to the hash table
  • I added the display function to display all the data entries in the hash table
  • I added the search_data function to find a specific data entry in the hash table
  • I added the amend_data function to amend the score of a specific data entry in the hash table
  • I added the remove_data function to remove a specific data entry in the table
  • I added comments to make my code readable

The output below is the same as in linked lists, hopefully hash table is actually faster.

Next entry will be about comparing hash tables, linked list, and dynamic array.

Attachment
0
Vulcan

Last Devlog of Linked Lists

I realised I had a really weird insertion logic, so I changed it to just appending at the head, rather than second place in the list.
I also fixed some memory issues in the code

Attachment
0
Vulcan

Second Devlog of Linked Lists

  • I created an add_data function to add a data entry to the linked list
  • I created a remove_data function to remove a data entry from the linked list
Attachment
0
Vulcan

I’ve decided to not include sorting in this project.

First Devlog of Linked Lists

  • I created a load function in linked lists, which initialises a linked list with the data in the text file provided
  • I created an unload function, which frees all the memory in the linked list
  • I created a display function, which displays all the data in the linked list
Attachment
0
Vulcan

5th Devlog of Dynamic Arrays

Hopefully this is the penultimate devlog for the dynamic array data structure.

This morning I:

  • created an amend_data function, which amends the score of a user in the dynamic array
  • spaced out the main function so it’s readable
  • added a remove_data function, which deletes the data entry of the user with the username given as a parameter, and returns the pointer to the new memory
  • changed char username[50] to const char *username in most places, since I don’t want it to change
  • found a more efficient way of splitting line into score and username using sscanf
  • removed memory allocation from remove_data, since it’s not needed

Now all that’s left to do is create the sort_data function, in which I’m planning on using merge sort.

Attachment
Attachment
Attachment
0
Vulcan

4th Devlog of Dynamic Arrays

  • I added the add_data function which adds a data entry to the dynamic entry, and returns the new pointer
  • I added the search_data function which searches for the score of the user with the username given in the parameter
  • I added comments to the functions for readability
Attachment
Attachment
0
Vulcan

3rd Devlog of Dynamic Arrays

  • I made the load function more robust so it increments size more logically, and it closes files if a pointer fails to be created
  • I added an unload function, which simply contains one line to free the pointer (dynamic arrays are easy to free)
  • I also added a display function which goes through all the entries in the dynamic array and displays each one
Attachment
Attachment
0
Vulcan

2nd Devlog of Dynamic Arrays

  • I’ve almost finished coding the load function, which reads the data from a text file and adds it to the dynamic array
  • I got a little sidetracked by creating my own implementation of a split function, but I can parse the data from the text file now
  • I’m aware of the memory leaks, but I will handle that in the unload function, which I’m going to code next
Attachment
Attachment
0
Vulcan

I’ve changed the idea of this project a little, although it’ll still be exploring memory in C

The project will contain a data type of a leaderboard entry, and I’ll include different ways of storing multiple leaderboard entries as different data structures.
I’ll definitely be doing:

  • Hash Table
  • Dynamic Array
  • Linked List

And I’m also planning on researching and implementing 2 others.

Today’s Update

I’ve started working on the dynamic array, and have structured out the different functions that I’ll need to implement

Attachment
0
Vulcan
  • i learnt the basics of c
  • i decided i want to make a project which contains several programs that manage memory
  • i started working on the grade book program (the first one)
Attachment
0