Skip to content

Add memory allocator and a subset of smart pointers #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

vbe0201
Copy link
Member

@vbe0201 vbe0201 commented Sep 14, 2019

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_ptr and std::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.
  • No support for heap allocations.

  • No implementation of weak_ptr as 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.

@Kaenbyo
Copy link
Member

Kaenbyo commented Sep 15, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants