mirror of
https://github.com/opnsense/src.git
synced 2026-07-16 12:33:07 -04:00
To permit checking the sources out on systems such as Windows with more restrictive file name requirements, rename the manpage source files to replace colons with underscrores. Use MANSRC.foo to point <bsd.man.mk> at the new source file names. Reviewed by: ivy Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D51794
50 lines
1.2 KiB
Groff
50 lines
1.2 KiB
Groff
.\"
|
|
.\" SPDX-License-Identifier: BSD-2-Clause
|
|
.\"
|
|
.\" Copyright (c) 2025 Chelsio Communications, Inc.
|
|
.\" Written by: John Baldwin <jhb@FreeBSD.org>
|
|
.\"
|
|
.Dd July 31, 2025
|
|
.Dt FREEBSD::MALLOC_UP 3
|
|
.Os
|
|
.Sh NAME
|
|
.Nm freebsd::malloc_up
|
|
.Nd std::unique_ptr specialization for objects allocated via malloc
|
|
.Sh LIBRARY
|
|
.Lb libutil++
|
|
.Sh SYNOPSIS
|
|
.In libutil++.hh
|
|
.Ft using malloc_up = std::unique_ptr<T, free_deleter<T>>;
|
|
.Sh DESCRIPTION
|
|
This class is a specialization of
|
|
.Vt std::unique_ptr
|
|
which invokes
|
|
.Xr free 3
|
|
instead of
|
|
.Fn delete
|
|
when an object is disposed.
|
|
While explicit calls to
|
|
.Xr malloc 3
|
|
should be avoided in C++ code,
|
|
this class can be useful to manage an object allocated by an existing API
|
|
which uses
|
|
.Xr malloc 3
|
|
internally such as
|
|
.Xr scandir 3 .
|
|
Note that the type of the underlying object must be used as the first
|
|
template argument similar to std::unique_ptr.
|
|
.Sh EXAMPLES
|
|
This example uses
|
|
.Xr strdup 3
|
|
for simplicity,
|
|
but new C++ code should generally not use
|
|
.Xr strdup 3 :
|
|
.Bd -literal -offset indent
|
|
freebsd::malloc_up<char> my_string(strdup("foo"));
|
|
// `mystring' is implicitly freed on destruction
|
|
.Ed
|
|
.Sh SEE ALSO
|
|
.Xr free 3 ,
|
|
.Xr malloc 3 ,
|
|
.Xr scandir 3 ,
|
|
.Xr strdup 3
|