summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/malloc.3
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2018-11-21 06:57:04 +0000
committerotto <otto@openbsd.org>2018-11-21 06:57:04 +0000
commitacb3f83f5f2f906963ced527da63eb9d54d45cd5 (patch)
tree39a92d8c41fce34de479bc4fae6271334afc3d1c /lib/libc/stdlib/malloc.3
parentwhen printing essids return the number of chars we printed, like printf (diff)
downloadwireguard-openbsd-acb3f83f5f2f906963ced527da63eb9d54d45cd5.tar.xz
wireguard-openbsd-acb3f83f5f2f906963ced527da63eb9d54d45cd5.zip
Introducing malloc_usable_size() was a mistake. While some other
libs have it, it is a function that is considered harmful, so: Delete malloc_usable_size(). It is a function that blurs the line between malloc managed memory and application managed memory and exposes some of the internal workings of malloc. If an application relies on that, it is likely to break using another implementation of malloc. If you want usable size x, just allocate x bytes. ok deraadt@ and other devs
Diffstat (limited to 'lib/libc/stdlib/malloc.3')
-rw-r--r--lib/libc/stdlib/malloc.331
1 files changed, 4 insertions, 27 deletions
diff --git a/lib/libc/stdlib/malloc.3 b/lib/libc/stdlib/malloc.3
index c1776f61cb8..c0472ee2b93 100644
--- a/lib/libc/stdlib/malloc.3
+++ b/lib/libc/stdlib/malloc.3
@@ -30,9 +30,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $OpenBSD: malloc.3,v 1.119 2018/11/18 16:15:18 otto Exp $
+.\" $OpenBSD: malloc.3,v 1.120 2018/11/21 06:57:04 otto Exp $
.\"
-.Dd $Mdocdate: November 18 2018 $
+.Dd $Mdocdate: November 21 2018 $
.Dt MALLOC 3
.Os
.Sh NAME
@@ -43,8 +43,7 @@
.Nm reallocarray ,
.Nm recallocarray ,
.Nm freezero ,
-.Nm aligned_alloc ,
-.Nm malloc_usable_size
+.Nm aligned_alloc
.Nd memory allocation and deallocation
.Sh SYNOPSIS
.In stdlib.h
@@ -65,7 +64,6 @@
.Ft void *
.Fn aligned_alloc "size_t alignment" "size_t size"
.Ft size_t
-.Fn malloc_usable_size "void *ptr"
.Vt char *malloc_options ;
.Sh DESCRIPTION
The standard functions
@@ -236,25 +234,6 @@ If
is not a multiple of
.Fa alignment ,
behavior is undefined.
-.Pp
-The
-.Fn malloc_usable_size
-function returns the actual size of the allocated memory pointed to by
-.Va ptr .
-If
-.Va ptr
-is
-.Dv NULL ,
-it returns 0.
-If
-.Va ptr
-was never returned by an allocation function or freed before,
-the behavior is undefined.
-This function should not be relied upon since it exposes some of the internal
-workings of the
-.Fn malloc
-family of functions.
-Writing beyond the requested size introduces undefined behavior.
.Sh RETURN VALUES
Upon successful completion, the allocation functions
return a pointer to the allocated space; otherwise,
@@ -640,9 +619,7 @@ function appeared in
.Ox 6.2 .
The
.Fn aligned_alloc
-and
-.Fn malloc_usable_size
-functions appeared in
+function appeared in
.Ox 6.5 .
.Sh CAVEATS
When using