This project implements a simple contacts directory using hash tables and linked lists. The code is thoroughly commented (in French) to aid understanding.
To compile and run the code, make sure your system has make
and a C compiler installed. You may also need valgrind
to test for memory leaks.
To compile the code, run:
$ make
Navigate to the tests
directory to run the available tests:
$ cd tests
$ ./directory-01-test # Run the first test as an example
Each test file evaluates different aspects of the contacts directory. Below is a description of each test:
- directory-01-test: Memory test (verifies if the
free_dir
function properly frees memory). - directory-02-test: Tests if contact insertion in the hash table works.
- directory-03-test: Similar to
directory-02
, but with three contacts. - directory-04-test: Tests if the
dir_lookup_num
function works as expected. - directory-05-test: Tests the functionality of the
dir_delete
function. - directory-06-test: Resizing test – adds a large number of contacts, causing the hash table to double in size.
- directory-07-test: Resizing test – deletes contacts, causing the hash table to shrink.
Feel free to add your tests or extend the functionality of the directory!
To run the first test:
$ ./directory-01-test
To check for memory leaks using valgrind
, you can run the following command:
$ valgrind ./directory-01-test # Example: running the memory test