Deleted Added
full compact
malloc.9 (177608) malloc.9 (184205)
1.\"
2.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
3.\" All rights reserved.
4.\"
5.\" This code is derived from software contributed to The NetBSD Foundation
6.\" by Paul Kranenburg.
7.\"
8.\" Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34.\" POSSIBILITY OF SUCH DAMAGE.
35.\"
36.\" $NetBSD: malloc.9,v 1.3 1996/11/11 00:05:11 lukem Exp $
1.\"
2.\" Copyright (c) 1996 The NetBSD Foundation, Inc.
3.\" All rights reserved.
4.\"
5.\" This code is derived from software contributed to The NetBSD Foundation
6.\" by Paul Kranenburg.
7.\"
8.\" Redistribution and use in source and binary forms, with or without

--- 20 unchanged lines hidden (view full) ---

29.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34.\" POSSIBILITY OF SUCH DAMAGE.
35.\"
36.\" $NetBSD: malloc.9,v 1.3 1996/11/11 00:05:11 lukem Exp $
37.\" $FreeBSD: head/share/man/man9/malloc.9 177608 2008-03-25 15:44:49Z ru $
37.\" $FreeBSD: head/share/man/man9/malloc.9 184205 2008-10-23 15:53:51Z des $
38.\"
38.\"
39.Dd June 12, 2003
39.Dd October 23, 2008
40.Dt MALLOC 9
41.Os
42.Sh NAME
43.Nm malloc ,
40.Dt MALLOC 9
41.Os
42.Sh NAME
43.Nm malloc ,
44.Nm MALLOC ,
45.Nm free ,
44.Nm free ,
46.Nm FREE ,
47.Nm realloc ,
48.Nm reallocf ,
49.Nm MALLOC_DEFINE ,
50.Nm MALLOC_DECLARE
51.Nd kernel memory management routines
52.Sh SYNOPSIS
53.In sys/types.h
54.In sys/malloc.h
55.Ft void *
56.Fn malloc "unsigned long size" "struct malloc_type *type" "int flags"
45.Nm realloc ,
46.Nm reallocf ,
47.Nm MALLOC_DEFINE ,
48.Nm MALLOC_DECLARE
49.Nd kernel memory management routines
50.Sh SYNOPSIS
51.In sys/types.h
52.In sys/malloc.h
53.Ft void *
54.Fn malloc "unsigned long size" "struct malloc_type *type" "int flags"
57.Fn MALLOC space cast "unsigned long size" "struct malloc_type *type" "int flags"
58.Ft void
59.Fn free "void *addr" "struct malloc_type *type"
55.Ft void
56.Fn free "void *addr" "struct malloc_type *type"
60.Fn FREE "void *addr" "struct malloc_type *type"
61.Ft void *
62.Fn realloc "void *addr" "unsigned long size" "struct malloc_type *type" "int flags"
63.Ft void *
64.Fn reallocf "void *addr" "unsigned long size" "struct malloc_type *type" "int flags"
65.Fn MALLOC_DECLARE type
66.In sys/param.h
67.In sys/malloc.h
68.In sys/kernel.h

--- 49 unchanged lines hidden (view full) ---

118.Pp
119The
120.Fn reallocf
121function is identical to
122.Fn realloc
123except that it
124will free the passed pointer when the requested memory cannot be allocated.
125.Pp
57.Ft void *
58.Fn realloc "void *addr" "unsigned long size" "struct malloc_type *type" "int flags"
59.Ft void *
60.Fn reallocf "void *addr" "unsigned long size" "struct malloc_type *type" "int flags"
61.Fn MALLOC_DECLARE type
62.In sys/param.h
63.In sys/malloc.h
64.In sys/kernel.h

--- 49 unchanged lines hidden (view full) ---

114.Pp
115The
116.Fn reallocf
117function is identical to
118.Fn realloc
119except that it
120will free the passed pointer when the requested memory cannot be allocated.
121.Pp
126The
127.Fn MALLOC
128macro variant is functionally equivalent to
129.Bd -literal -offset indent
130(space) = (cast)malloc((u_long)(size), type, flags)
131.Ed
132.Pp
133and the
134.Fn FREE
135macro variant is equivalent to
136.Bd -literal -offset indent
137free((addr), type)
138.Ed
139.Pp
140Unlike its standard C library counterpart
141.Pq Xr malloc 3 ,
142the kernel version takes two more arguments.
143The
144.Fa flags
145argument further qualifies
146.Fn malloc Ns 's
147operational characteristics as follows:

--- 66 unchanged lines hidden (view full) ---

214
215/* sys/something/foo_main.c */
216
217MALLOC_DEFINE(M_FOOBUF, "foobuffers", "Buffers to foo data into the ether");
218
219/* sys/something/foo_subr.c */
220
221\&...
122Unlike its standard C library counterpart
123.Pq Xr malloc 3 ,
124the kernel version takes two more arguments.
125The
126.Fa flags
127argument further qualifies
128.Fn malloc Ns 's
129operational characteristics as follows:

--- 66 unchanged lines hidden (view full) ---

196
197/* sys/something/foo_main.c */
198
199MALLOC_DEFINE(M_FOOBUF, "foobuffers", "Buffers to foo data into the ether");
200
201/* sys/something/foo_subr.c */
202
203\&...
222MALLOC(buf, struct foo_buf *, sizeof *buf, M_FOOBUF, M_NOWAIT);
204buf = malloc(sizeof *buf, M_FOOBUF, M_NOWAIT);
223
224.Ed
225.Pp
226In order to use
227.Fn MALLOC_DEFINE ,
228one must include
229.In sys/param.h
230(instead of

--- 78 unchanged lines hidden ---
205
206.Ed
207.Pp
208In order to use
209.Fn MALLOC_DEFINE ,
210one must include
211.In sys/param.h
212(instead of

--- 78 unchanged lines hidden ---