Skip to content

Commit 1353d07

Browse files
committed
inline alloc_slice.rs, other improvements
1 parent 016ea0b commit 1353d07

File tree

25 files changed

+964
-263
lines changed

25 files changed

+964
-263
lines changed

.idea/codeStyles/codeStyleConfig.xml

100644100755
File mode changed.

.idea/dictionaries/project.xml

100644100755
Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/memapi.iml

100644100755
File mode changed.

.idea/modules.xml

100644100755
File mode changed.

.idea/vcs.xml

100644100755
File mode changed.

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ _no versions before 0.13.2 have a changelog as I started the changelog in that v
66

77
- [Version 0.16.0 Predicted](#version-0160-predicted)
88
- [Version 0.15.0](#version-0150)
9+
- [Commit 9](#commit-9-2025-8-07)
10+
- [Commit 8](#commit-8-2025-8-07)
911
- [Commit 7](#commit-7-2025-8-06)
1012
- [Commit 6](#commit-6-2025-8-05)
1113
- [Commit 5](#commit-5-2025-8-05)
@@ -39,7 +41,19 @@ _no versions before 0.13.2 have a changelog as I started the changelog in that v
3941
- use helpers for repetitive code [size]
4042
- Split AllocSlice/AllocExt into multiple traits (only in consideration)
4143

42-
## Version 0.15.0
44+
## Version 0.15.0 (2025-8-07)
45+
46+
### Commit 9 (2025-8-07)
47+
48+
- Inline alloc_slice.rs
49+
- Improve lib.rs inlining
50+
- Fix formatting
51+
- Add some benchmarks
52+
- Use a build.rs to verify no UB before compiling
53+
- Separate `std` and `libc_std` to allow using `std` on lower versions of rust (and thus libc)
54+
- Comment out outdated portions of the readme
55+
- Add `AllocExt::alloc_guard_for`
56+
- Switch to manual overflow checks where necessary (using `helpers::checked_op[_panic[_const]]`)
4357

4458
### Commit 8 (2025-8-07)
4559

Cargo.toml

Lines changed: 71 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,100 @@
11
[package]
22
name = "memapi"
3-
# major will probably always be 0
4-
version = "0.14.3"
3+
version = "0.15.0"
54
edition = "2018"
6-
authors = ["echohumm"]
7-
readme = "README.md"
85
rust-version = "1.56.0"
6+
authors = ["echohumm"]
97
description = "A no_std-friendly memory allocation interface for raw buffers, with improved error reporting."
8+
readme = "README.md"
109
license = "MIT OR Apache-2.0"
1110
repository = "https://github.com/echohumm/memapi"
1211
keywords = ["allocator", "no_std", "memory", "allocation"]
1312
categories = ["no-std", "memory-management"]
1413
exclude = ["/tests", "/bin", "testall.py", "src/expanded"]
14+
build = "build.rs"
1515

1616
[package.metadata.docs.rs]
1717
features = ["full"]
1818

1919
[badges]
20-
maintenance = { status = "actively-developed" }
2120
docsrs = { status = "passing" }
21+
maintenance = { status = "actively-developed" }
2222

23-
# TODO: docs for features
23+
[profile.bench]
24+
opt-level = 3
25+
lto = true
26+
codegen-units = 1
27+
debug = false
28+
overflow-checks = false
2429

2530
[features]
26-
nightly = []
27-
std = ["libc/std"]
31+
default = ["c_str", "extra_extra_const"]
32+
33+
# msrv-changing features
34+
extra_const = []
35+
extra_extra_const = ["extra_const"]
36+
c_str = []
2837

38+
# nightly support
39+
nightly = []
2940
metadata = ["nightly"]
3041
sized_hierarchy = ["nightly"]
3142
clone_to_uninit = ["nightly"]
3243
specialization = ["nightly"]
3344

34-
extra_const = []
35-
extra_extra_const = ["extra_const"]
36-
c_str = []
37-
3845
all_nightly = ["metadata", "sized_hierarchy", "clone_to_uninit", "specialization"]
46+
3947
default_nightly = ["metadata", "clone_to_uninit", "specialization"]
4048

49+
# std support
50+
std = []
51+
std_with_libc = ["std", "libc/std"]
52+
53+
# main extensions
4154
alloc_ext = []
4255
alloc_slice = []
4356
resize_in_place = []
4457

58+
# stats
4559
stats = []
4660

61+
# external allocators
4762
external_alloc = ["libc"]
48-
4963
jemalloc = ["memapi-jemalloc-sys", "external_alloc"]
5064
jemalloc_in_place = ["jemalloc", "resize_in_place"]
51-
5265
mimalloc = ["memapi-mimalloc-sys", "external_alloc"]
5366
mimalloc_in_place = ["mimalloc", "resize_in_place"]
54-
5567
external_allocs = ["jemalloc", "mimalloc"]
5668
external_allocs_in_place = ["jemalloc_in_place", "mimalloc_in_place"]
5769

58-
full_min = [
59-
"alloc_slice",
60-
"alloc_ext",
61-
"stats",
62-
]
63-
64-
full_min_std = [
65-
"full_min",
66-
"std",
67-
]
68-
70+
# bundles
71+
full_min = ["alloc_slice", "alloc_ext", "stats"]
72+
full_min_std = ["full_min", "std"]
6973
full_no_std_no_nightly = [
70-
# new versions
7174
"c_str",
7275
"extra_extra_const",
73-
# extern
7476
"external_allocs_in_place",
75-
7677
"full_min",
7778
]
79+
full_no_nightly = ["std", "full_no_std_no_nightly"]
80+
full_no_std = ["all_nightly", "full_no_std_no_nightly"]
81+
full = ["full_no_nightly", "full_no_std"]
7882

79-
full_no_nightly = [
80-
"std",
81-
"full_no_std_no_nightly"
82-
]
83-
84-
full_no_std = [
85-
"all_nightly",
86-
"full_no_std_no_nightly",
87-
]
88-
89-
full = [
90-
"full_no_nightly",
91-
"full_no_std"
83+
# jemalloc feature tweaks
84+
jemalloc_background_threads_runtime_support = ["memapi-jemalloc-sys/background_threads_runtime_support"]
85+
jemalloc_background_threads = [
86+
"jemalloc_background_threads_runtime_support",
87+
"memapi-jemalloc-sys/background_threads",
9288
]
89+
jemalloc_debug = ["memapi-jemalloc-sys/debug"]
90+
jemalloc_default = ["jemalloc_background_threads_runtime_support", "memapi-jemalloc-sys/default"]
91+
jemalloc_disable_cache_oblivious = ["memapi-jemalloc-sys/disable_cache_oblivious"]
92+
jemalloc_disable_initial_exec_tls = ["memapi-jemalloc-sys/disable_initial_exec_tls"]
93+
jemalloc_profiling = ["memapi-jemalloc-sys/profiling"]
94+
jemalloc_stats = ["memapi-jemalloc-sys/stats"]
95+
jemalloc_unprefixed_malloc_on_supported_platforms = ["memapi-jemalloc-sys/unprefixed_malloc_on_supported_platforms"]
9396

94-
default = ["c_str", "extra_extra_const"]
95-
97+
# mimalloc variants
9698
mimalloc_arena = ["memapi-mimalloc-sys/arena"]
9799
mimalloc_debug = ["memapi-mimalloc-sys/debug"]
98100
mimalloc_debug_in_debug = ["memapi-mimalloc-sys/debug_in_debug"]
@@ -101,35 +103,19 @@ mimalloc_no_thp = ["memapi-mimalloc-sys/no_thp"]
101103
mimalloc_override = ["memapi-mimalloc-sys/override"]
102104
mimalloc_secure = ["memapi-mimalloc-sys/secure"]
103105

104-
jemalloc_background_threads_runtime_support = ["memapi-jemalloc-sys/background_threads_runtime_support"]
105-
jemalloc_background_threads = ["jemalloc_background_threads_runtime_support", "memapi-jemalloc-sys/background_threads"]
106-
jemalloc_debug = ["memapi-jemalloc-sys/debug"]
107-
jemalloc_default = ["jemalloc_background_threads_runtime_support", "memapi-jemalloc-sys/default"]
108-
jemalloc_disable_cache_oblivious = ["memapi-jemalloc-sys/disable_cache_oblivious"]
109-
jemalloc_disable_initial_exec_tls = ["memapi-jemalloc-sys/disable_initial_exec_tls"]
110-
jemalloc_profiling = ["memapi-jemalloc-sys/profiling"]
111-
jemalloc_stats = ["memapi-jemalloc-sys/stats"]
112-
jemalloc_unprefixed_malloc_on_supported_platforms = ["memapi-jemalloc-sys/unprefixed_malloc_on_supported_platforms"]
113-
114106
[[test]]
115107
name = "base"
116108
path = "tests/alloc.rs"
117109

110+
[[test]]
111+
name = "dangerous"
112+
path = "tests/potential_ub.rs"
113+
118114
[[test]]
119115
name = "ext"
120116
path = "tests/alloc_ext.rs"
121117
required-features = ["alloc_ext"]
122118

123-
[[test]]
124-
name = "slice"
125-
path = "tests/alloc_slice.rs"
126-
required-features = ["alloc_slice"]
127-
128-
[[test]]
129-
name = "stats"
130-
path = "tests/stats.rs"
131-
required-features = ["stats", "std"]
132-
133119
[[test]]
134120
name = "jem"
135121
path = "tests/jemalloc.rs"
@@ -141,10 +127,28 @@ path = "tests/mimalloc.rs"
141127
required-features = ["mimalloc"]
142128

143129
[[test]]
144-
name = "dangerous"
145-
path = "tests/potential_ub.rs"
130+
name = "slice"
131+
path = "tests/alloc_slice.rs"
132+
required-features = ["alloc_slice"]
133+
134+
[[test]]
135+
name = "stats"
136+
path = "tests/stats.rs"
137+
required-features = ["stats", "std"]
138+
139+
# if this crate is ever built with a version above msrv, it will stop compiling because of this.
140+
# darn you, Cargo.lock
141+
[dev-dependencies.criterion]
142+
version = "^0.4.0"
143+
default-features = false
144+
145+
[[bench]]
146+
name = "bench"
147+
path = "benches/bench.rs"
148+
harness = false
149+
required-features = ["alloc_ext"]
146150

147151
[dependencies]
148-
libc = { version = "^0.2", optional = true, default-features = false }
152+
libc = { version = "^0.2.0", optional = true, default-features = false }
149153
memapi-jemalloc-sys = { version = "0.1.1", optional = true }
150154
memapi-mimalloc-sys = { version = "0.1.2", optional = true, features = ["extended"] }

LICENSE-APACHE

100644100755
File mode changed.

0 commit comments

Comments
 (0)