xref: /netbsd-src/lib/libbsdmalloc/bsdmalloc.3 (revision 5c44d8113a97125dd4098a6fc5654a3fd1dc1a5c)
1*5c44d811Suwe.\"	$NetBSD: bsdmalloc.3,v 1.3 2023/07/06 01:32:52 uwe Exp $
22daa8bfeSriastradh.\"
32daa8bfeSriastradh.\" Copyright (c) 2023 The NetBSD Foundation, Inc.
42daa8bfeSriastradh.\" All rights reserved.
52daa8bfeSriastradh.\"
62daa8bfeSriastradh.\" Redistribution and use in source and binary forms, with or without
72daa8bfeSriastradh.\" modification, are permitted provided that the following conditions
82daa8bfeSriastradh.\" are met:
92daa8bfeSriastradh.\" 1. Redistributions of source code must retain the above copyright
102daa8bfeSriastradh.\"    notice, this list of conditions and the following disclaimer.
112daa8bfeSriastradh.\" 2. Redistributions in binary form must reproduce the above copyright
122daa8bfeSriastradh.\"    notice, this list of conditions and the following disclaimer in the
132daa8bfeSriastradh.\"    documentation and/or other materials provided with the distribution.
142daa8bfeSriastradh.\"
152daa8bfeSriastradh.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
162daa8bfeSriastradh.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
172daa8bfeSriastradh.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
182daa8bfeSriastradh.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
192daa8bfeSriastradh.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
202daa8bfeSriastradh.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
212daa8bfeSriastradh.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
222daa8bfeSriastradh.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
232daa8bfeSriastradh.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
242daa8bfeSriastradh.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
252daa8bfeSriastradh.\" POSSIBILITY OF SUCH DAMAGE.
262daa8bfeSriastradh.\"
272daa8bfeSriastradh.Dd July 4, 2023
282daa8bfeSriastradh.Dt BSDMALLOC 3
292daa8bfeSriastradh.Os
302daa8bfeSriastradh.Sh NAME
312daa8bfeSriastradh.Nm bsdmalloc
322daa8bfeSriastradh.Nd lightweight historic BSD memory allocator replacement
332daa8bfeSriastradh.Sh LIBRARY
342daa8bfeSriastradh.Lb libbsdmalloc
352daa8bfeSriastradh.Sh SYNOPSIS
362daa8bfeSriastradh.In stdlib.h
372daa8bfeSriastradh.Ft void *
38*5c44d811Suwe.Fn malloc "size_t size"
392daa8bfeSriastradh.Ft void *
402daa8bfeSriastradh.Fn calloc "size_t nmemb" "size_t size"
412daa8bfeSriastradh.Ft void *
422daa8bfeSriastradh.Fn realloc "void *ptr" "size_t size"
432daa8bfeSriastradh.Ft void *
442daa8bfeSriastradh.Fn aligned_alloc "size_t alignment" "size_t size"
452daa8bfeSriastradh.Ft int
462daa8bfeSriastradh.Fn posix_memalign "void **memptr" "size_t alignment" "size_t size"
472daa8bfeSriastradh.Ft void
482daa8bfeSriastradh.Fn free "void *ptr"
492daa8bfeSriastradh.Ft void
503cc9538eSrillig.Fn _malloc_prefork "void"
512daa8bfeSriastradh.Ft void
523cc9538eSrillig.Fn _malloc_postfork "void"
532daa8bfeSriastradh.Ft void
543cc9538eSrillig.Fn _malloc_postfork_child "void"
552daa8bfeSriastradh.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
562daa8bfeSriastradh.Sh DESCRIPTION
572daa8bfeSriastradhThe
582daa8bfeSriastradh.Nm
592daa8bfeSriastradhlibrary provides a lower-performance but smaller-size drop-in
602daa8bfeSriastradhreplacement for the standard
612daa8bfeSriastradh.Xr malloc 3
622daa8bfeSriastradhfamily of functions provided by
632daa8bfeSriastradh.Lb libc ,
642daa8bfeSriastradhas well as internal hooks for
652daa8bfeSriastradh.Xr fork 2
662daa8bfeSriastradhsafety in multithreaded programs.
672daa8bfeSriastradh.Pp
682daa8bfeSriastradhPrograms can be statically linked with
692daa8bfeSriastradh.Li -lbsdmalloc
702daa8bfeSriastradhfor smaller code footprint, at a higher cost to run-time performance
712daa8bfeSriastradhand scalability and limited diagnostics.
722daa8bfeSriastradh.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
732daa8bfeSriastradh.Sh SEE ALSO
742daa8bfeSriastradh.Xr malloc 3 ,
752daa8bfeSriastradh.Xr posix_memalign 3
762daa8bfeSriastradh.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
772daa8bfeSriastradh.Sh BUGS
782daa8bfeSriastradh.Nm Ns No 's
792daa8bfeSriastradhimplementation of
802daa8bfeSriastradh.Fn malloc ,
812daa8bfeSriastradh.Fn calloc ,
822daa8bfeSriastradhand
832daa8bfeSriastradh.Fn realloc
842daa8bfeSriastradhdoesn't correctly set
852daa8bfeSriastradh.Xr errno 2
862daa8bfeSriastradhon failure.
87