mcpp index

compat.mimalloc

#include

mimalloc — compact general-purpose allocator with excellent performance

#include <mimalloc.h>
mcpp add compat.mimalloc@3.4.5

用法

來自本倉庫自己的測試專案 —— CI 真的編譯並執行過,不是為了網站寫的。

// compat.mimalloc — assert the allocator is real, not just that it links.
//
// Every check below can fail: mi_usable_size reports what mimalloc actually
// reserved (so it proves the pointer came from mimalloc's own bookkeeping and
// not from a fallback), mi_zalloc must return zeroed memory, and a private
// heap must be able to hand out and destroy blocks independently of the
// default heap.
#include <mimalloc.h>
import std;

int main() {
    bool ok = true;

    auto check = [&](bool cond, std::string_view what) {
        if (!cond) {
            std::println("FAIL: {}", what);
            ok = false;
        }
    };

    // 1. Basic allocation, and mimalloc knows the block's real size.
    void* p = mi_malloc(1024);
// …

tests/examples/mimalloc/tests/alloc.cpp · 專案 tests/examples/mimalloc

建置

targets
mimalloc (lib)
language
c++23
C standard
c11
import std
no
include dirs
*/include

原始檔 (18)

  • */src/alloc.c
  • */src/alloc-aligned.c
  • */src/alloc-posix.c
  • */src/arena.c
  • */src/arena-meta.c
  • */src/bitmap.c
  • */src/heap.c
  • */src/init.c
  • */src/libc.c
  • */src/options.c
  • */src/os.c
  • */src/page.c
  • */src/page-map.c
  • */src/random.c
  • */src/stats.c
  • */src/theap.c
  • */src/threadlocal.c
  • */src/prim/prim.c

版本

版本平台 鏡像sha256
3.4.5 最新 LinuxWindowsmacOS GLOBAL CN 19a43af0645c…