3882 Remove xmod & friends
[illumos-gate.git] / usr / src / uts / common / smbsrv / alloc.h
blob3a2ca863685b1f42a5af62b704650f0767a606c0
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SMBSRV_ALLOC_H
27 #define _SMBSRV_ALLOC_H
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
34 * Memory management macros to aid in developing code that can
35 * be compiled for both user and kernel.
37 * Set the AREA parameter to a short text string that is a hint
38 * about the subsystem calling the function. example: "smbrdr"
40 * Do not mix usage of these macros with malloc/free functions.
41 * It will not work.
43 * All library code shared between user and kernel must use
44 * these functions instead of malloc/free/kmem_*.
46 * Quick Summary
47 * MEM_MALLOC - allocate memory
48 * MEM_ZALLOC - allocate and zero memory
49 * MEM_STRDUP - string copy
50 * MEM_REALLOC - reallocate memory
51 * MEM_FREE - free memory
54 #include <sys/types.h>
55 #include <sys/sysmacros.h>
57 #ifndef _KERNEL
58 #include <stdlib.h>
59 #include <string.h>
61 #define MEM_MALLOC(AREA, SIZE) malloc(SIZE)
62 #define MEM_ZALLOC(AREA, SIZE) calloc((SIZE), 1)
63 #define MEM_STRDUP(AREA, PTR) strdup(PTR)
64 #define MEM_REALLOC(AREA, PTR, SIZE) realloc((PTR), (SIZE))
65 #define MEM_FREE(AREA, PTR) free(PTR)
67 #else /* _KERNEL */
69 void *smb_mem_alloc(size_t);
70 void *smb_mem_zalloc(size_t);
71 void smb_mem_free(void *);
72 char *smb_mem_strdup(const char *);
74 #define MEM_MALLOC(AREA, SIZE) smb_mem_alloc(SIZE)
75 #define MEM_ZALLOC(AREA, SIZE) smb_mem_zalloc(SIZE)
76 #define MEM_FREE(AREA, PTR) smb_mem_free(PTR)
78 #endif /* _KERNEL */
80 #ifdef __cplusplus
82 #endif
84 #endif /* _SMBSRV_ALLOC_H */