7712 mandoc -Tlint does always exit with error code 0
[unleashed.git] / usr / src / cmd / lvm / rpc.metamhd / mhd_mem.c
blobc7e6855a4adcbb760ca184d1840707d4f608b589
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
24 * Copyright (c) 1994, 2000 by Sun Microsystems, Inc.
25 * All rights reserved.
28 #pragma ident "%Z%%M% %I% %E% SMI"
30 #include "mhd_local.h"
32 void
33 Free(
34 void *p
37 free(p);
40 void *
41 Malloc(
42 size_t s
45 void *mem;
47 if ((mem = malloc(s)) == NULL) {
48 mhd_perror("");
49 mhd_exit(1);
51 return (mem);
54 void *
55 Zalloc(
56 size_t s
59 return (memset(Malloc(s), 0, s));
62 void *
63 Realloc(
64 void *p,
65 size_t s
68 if (p == NULL)
69 p = malloc(s);
70 else
71 p = realloc(p, s);
72 if (p == NULL) {
73 mhd_perror("");
74 mhd_exit(1);
76 return (p);
79 void *
80 Calloc(
81 size_t n,
82 size_t s
85 unsigned long total;
87 if (n == 0 || s == 0) {
88 total = 0;
89 } else {
90 total = (unsigned long)n * s;
91 /* check for overflow */
92 if (total / n != s)
93 return (NULL);
95 return (Zalloc(total));
98 char *
99 Strdup(
100 const char *p
103 char *n;
105 if ((n = strdup(p)) == NULL) {
106 mhd_perror("");
107 mhd_exit(1);
109 return (n);