Add memory allocator and a subset of smart pointers
Summary
As discussed on Discord, this Pull Request mainly adds a memory allocator which is capable of mapping and managing a given memory region and implementations for shared_ptr and unqiue_ptr.
I also made the fix_codestyle script executable under Linux and reformatted everything with Clang-Format.
Goals
-
Adequate replacement for
std::shared_ptrandstd::unqiue_ptr. -
Free of dependencies.
-
Lightweight implementation.
-
Clean and fast code.
-
Good documentation for Doxygen.
Limitations
-
Neither the memory allocator nor the smart pointers can be considered thread-safe.
- Can be resolved by using a
hs::os::Mutex.
- Can be resolved by using a
-
No support for heap allocations.
-
No implementation of
weak_ptras I didn't consider it necessary.- If there's a demand, I can add it.
-
Only a subset of the smart pointers is actually implemented.
- The implementations can be extended if necessary.
For reference:
We now have a shared_ptr/unique_ptr implementation that differ from the std counterpart. This is mainly because we don't follow the allocator_traits requirements.
I also rewrote the memory allocator to use a simple free list (this still uses a first fit algorithm but I guess it's clearly enough for now).
The doc still need to be updated and some small optimization can be done on the free list fragmentation.