1.\" $NetBSD: bsdmalloc.3,v 1.3 2023/07/06 01:32:52 uwe Exp $ 2.\" 3.\" Copyright (c) 2023 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25.\" POSSIBILITY OF SUCH DAMAGE. 26.\" 27.Dd July 4, 2023 28.Dt BSDMALLOC 3 29.Os 30.Sh NAME 31.Nm bsdmalloc 32.Nd lightweight historic BSD memory allocator replacement 33.Sh LIBRARY 34.Lb libbsdmalloc 35.Sh SYNOPSIS 36.In stdlib.h 37.Ft void * 38.Fn malloc "size_t size" 39.Ft void * 40.Fn calloc "size_t nmemb" "size_t size" 41.Ft void * 42.Fn realloc "void *ptr" "size_t size" 43.Ft void * 44.Fn aligned_alloc "size_t alignment" "size_t size" 45.Ft int 46.Fn posix_memalign "void **memptr" "size_t alignment" "size_t size" 47.Ft void 48.Fn free "void *ptr" 49.Ft void 50.Fn _malloc_prefork "void" 51.Ft void 52.Fn _malloc_postfork "void" 53.Ft void 54.Fn _malloc_postfork_child "void" 55.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 56.Sh DESCRIPTION 57The 58.Nm 59library provides a lower-performance but smaller-size drop-in 60replacement for the standard 61.Xr malloc 3 62family of functions provided by 63.Lb libc , 64as well as internal hooks for 65.Xr fork 2 66safety in multithreaded programs. 67.Pp 68Programs can be statically linked with 69.Li -lbsdmalloc 70for smaller code footprint, at a higher cost to run-time performance 71and scalability and limited diagnostics. 72.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 73.Sh SEE ALSO 74.Xr malloc 3 , 75.Xr posix_memalign 3 76.\""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 77.Sh BUGS 78.Nm Ns No 's 79implementation of 80.Fn malloc , 81.Fn calloc , 82and 83.Fn realloc 84doesn't correctly set 85.Xr errno 2 86on failure. 87