Skip to content

A runtime library that defines a safe context for C++, no reference counting involved.

License

Notifications You must be signed in to change notification settings

QuantumBoy1010/Safe-Cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Safe

Safe is a runtime library that defines a safe context for C++. It tracks every heap-allocated instance of types that inherit from Safe::SafeContextBase and offers recycling/repurpose mechanisms, using only C++ standard library.

📥 Download & Installation

Download the library package for your platform. Extract the package to your project directory and specify the paths to the library's header files. Link to the library files (.sll,.dll, .a or .so) by adding to the dependency inputs. If you want to use the dynamic library, copy the library file(s) to the folder(s) of the output executable(s).

Note

On Windows, in order to avoid the confusion between the .lib files that go with .dll in dynamic libraries, Safe will use .sll as the file extension for static libraries. Linking to the static libraries with .sll extension is fine like linking to .lib files in other projects. All library packages are thoroughly scanned with ESET Smart Security Premium on a Windows 10 environment prior to release to ensure they are free of malicious code.

📖 Reference & Guide

Navigate to Reference to view API reference and Guide to view guide.

💡 Examples

class Example : public Safe::SafeContextBase //or `class Example safe`
{
public:
	Example()
	{
		
	};
	Example(const Example& other) noexcept
	{
		
	};
	Example(Example&& other) noexcept
	{
		
	};
	~Example() override = default;


	Example& operator=(const Example& other) noexcept
	{
		return *this;
	};

	Example& operator=(Example&& other) noexcept
	{
		return *this;
	};
};

int main()
{
	Example* pointer = ::new Example();
	Example* anotherPointer = ::new Example();
	Example* pointerAlias = pointer;
	Safe::SafeContextBase::recycle(dynamic_cast<Safe::SafeContextBase*>(pointer)); // `pointer` is no longer meaningful after recycling.
	Example& repurposedReference = Safe::SafeContextBase::repurpose<Example>();
	// No need to deallocate via `pointer`, `anotherPointer` or `pointerAlias` anymore. Doing so will lead to program termination or even compilation error(s).

	return 0;
};

✍️ Authors

Duc Nguyen (https://www.github.com/QuantumBoy1010/)

🛠️ Feedback & Error reports

This project is a result of ongoing research. If you encounter any issues, find a bug in the headers, or have suggestions for performance improvements, your feedback is highly valued!

  • GitHub Issues: Please use the Issues tab to report technical errors or bugs.
  • Email: For detailed feedback or private inquiries, feel free to reach out to me directly at workofduc@gmail.com.
  • Feature Requests: If you have a specific use case that the current runtime doesn't cover, I'd love to hear about it.

💖 Support the Project

If you find this runtime library useful for your research or hobby projects, consider supporting my work. Your sponsorship helps me dedicate more time to optimizing memory management research, fixing errors and keeping the engine up to date.

⚖️ License

This library project is licensed under the PolyForm Non-commercial License 1.0.0.
Non-commercial/Educational Use: Free.
Commercial Use: Prohibited without a separate commercial license.
Please contact workofduc@gmail.com for pricing and licensing terms.

About

A runtime library that defines a safe context for C++, no reference counting involved.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages