Skip to content

Commit

Permalink
phil-opp/blog_os#1307: bump version and publish
Browse files Browse the repository at this point in the history
  • Loading branch information
kennystrawnmusic committed Mar 30, 2024
1 parent b3ccee8 commit 2d63b92
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "lazy-heap"
description = "A lazy heap allocator for Rust based on `slab_allocator_rs`."
repository = "https://github.com/kennystrawnmusic/lazy-heap"
version = "0.1.1-alpha.5"
version = "0.1.1-alpha.6"
edition = "2021"
license = "LGPL-3.0-or-later"
categories = [ "no-std", "memory-management" ]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `lazy_heap`: A wrapper around the `slab_allocator_rs` crate that allows for lazy initialization

Although there are plenty of global allocators in the crates.io repository, 3 years of tinkering with my own kernel code have taught me that, sometimes, the more time saved, the better. As such, I came up with this in the code to my own kernel but decided, because of just how useful it really is, to actually open it up to the masses.
Although there are plenty of global allocators in the crates.io repository, 3 years of tinkering with [my own kernel code](https://github.com/kennystrawnmusic/cryptos) have taught me that, sometimes, the more time saved, the better. As such, I came up with this in the code to my own kernel but decided, because of just how useful it really is, to actually open it up to the masses.

Using this crate allows you to use a closure to initialize the heap automatically (lazily) on the first access attempt:

Expand Down
17 changes: 17 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
//! # `lazy_heap`: A wrapper around the `slab_allocator_rs` crate that allows for lazy initialization
//!
//! Although there are plenty of global allocators in the crates.io repository, 3 years of tinkering with [my own kernel code](https://github.com/kennystrawnmusic/cryptos) have taught me that, sometimes, the more time saved, the better. As such, I came up with this in the code to my own kernel but decided, because of just how useful it really is, to actually open it up to the masses.
//!
//! ## Usage
//! Using this crate allows you to use a closure to initialize the heap automatically (lazily) on the first access attempt:
//!
//! ```rust
//! use lazy_heap::LazyHeap;
//! #[global_allocator]
//! pub static ALLOC: LazyHeap = LazyHeap::new(|| {
//! // allocator initialization code goes here
//! })
//! ```
//!
//! This is a much more seamless, much less error-prone, set-it-and-forget-it way to initialize heap allocation than any other approach, because, with it, you can be guaranteed that any first attempt to use `alloc` will automatically initialize the heap for you.

use core::alloc::{GlobalAlloc, Layout};
use spin::Lazy;

Expand Down

0 comments on commit 2d63b92

Please sign in to comment.