From 829ace403fa22dae1d4971f20ae1e2a354b05b1f Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Wed, 3 Oct 2018 14:37:05 -0400 Subject: [PATCH] document free_sized API --- malloc.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/malloc.h b/malloc.h index 402f95b..e59875f 100644 --- a/malloc.h +++ b/malloc.h @@ -85,6 +85,16 @@ size_t h_malloc_object_size(void *ptr); // similar to malloc_object_size, but avoiding locking so the results are much more limited size_t h_malloc_object_size_fast(void *ptr); +// The free function with an extra parameter for passing the size requested at +// allocation time. +// +// This offers the same functionality as C++14 sized deallocation and can be +// used to implement it. +// +// A performance-oriented allocator would use this as a performance +// enhancement with undefined behavior on a mismatch. Instead, this hardened +// allocator implementation uses it to improve security by checking that the +// passed size matches the allocated size. void h_free_sized(void *ptr, size_t expected_size); #endif