> mkdir build
> cd build
> cmake ..
> make
> valgrind valgrind_params path/to/binary binary_params, eg:
> valgrind --leak-check=full ./ResourceD 5
- Compile and run under valgrind all applications from examples directory
- Check valgrind errors
- Compile and run ResourceD application and check memory leaks under valgrind
- Fix memory leaks with a proper usage of delete operator
- Refactor the solution to use
std::unique_ptr<>
- Use
std::make_unique
- Compile and run ResourceFactory application
- Put comments in places where you can spot some problems
- How to remove elements from the collection (
vector<Resource*> resources
)? - Check memory leaks
- Fix problems
Take a look at List.cpp file, where simple (and buggy) single-linked list is implemented.
void add(Node* node)
method adds a new Node at the end of the list
Node* get(const int value)
method iterate over the list and returns the first Node with matching value or nullptr
- Compile and run List application
- Fix memory leaks without introducing smart pointers
- Fix memory leaks with smart pointers. What kind of pointers needs to be applied and why?
- What happens when the same Node is added twice? Fix this problem.
- (Optional) Create
EmptyListError
exception (deriving fromstd::runtime_error
). Add throwing and catching it in a proper places.
You can work in groups or individually. Please fork the repo and submit a Pull Request after you have finished.
-
Transform the list from List.cpp into double-linked list. You should implement:
- inserting Nodes at the beginning of the list
- searching elements from the backward Apply proper smart pointers for the reverse direction.
-
Implement your own unique_ptr. Requirements:
- Templatized (should hold a pointer to a template type)
- RAII (acquire in constructor, release in destructor)
- Copying not allowed
- Moving allowed
- Member functions:
operator*()
,operator->()
,get()
,release()
,reset()
-
Read one of these articles on move semantics:
- Semantyka przenoszenia (in Polish)
- Move semantics and rvalue references in C++11 (in English)