Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions parity-util-mem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog].
[Keep a Changelog]: http://keepachangelog.com/en/1.0.0/

## [Unreleased]
### Breaking
- Prevent multiple versions from being linked into the same program. [#363](https://github.com/paritytech/parity-common/pull/363)

## [0.6.0] - 2020-03-13
- Updated dependencies. [#361](https://github.com/paritytech/parity-common/pull/361)
Expand Down
7 changes: 7 additions & 0 deletions parity-util-mem/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ description = "Collection of memory related utilities"
license = "MIT/Apache-2.0"
edition = "2018"

# Prevent multiple versions from being linked into the same program.
Comment thread
ordian marked this conversation as resolved.
links = "parity-util-mem-ban-duplicates"
# `links` requires a build script to be present:
# https://doc.rust-lang.org/cargo/reference/build-scripts.html#the-links-manifest-key
# so we use an empty build script
build = "build.rs"

[dependencies]
cfg-if = "0.1.10"
dlmalloc = { version = "0.1.3", features = ["global"], optional = true }
Expand Down
14 changes: 14 additions & 0 deletions parity-util-mem/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

Collection of memory related utilities.

## WARNING

When `parity-util-mem` is used as a dependency with any of the global allocator features enabled,
it must be the sole place where a global allocator is defined.
The only exception to this rule is when used in a `no_std` context or when the `estimate-heapsize` feature is used.

Because of that, it must be present in the dependency tree with a single version.
Starting from version 0.7, having duplicate versions of `parity-util-mem` will lead
to a compile-time error. It still will be possible to have 0.6 and 0.7 versions in the same binary though.

Unless heeded you risk UB; see discussion in [issue 364].

[issue 364]: https://github.com/paritytech/parity-common/issues/364

## Features

- estimate-heapsize : Do not use allocator, but `size_of` or `size_of_val`.
Expand Down
1 change: 1 addition & 0 deletions parity-util-mem/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fn main() {}