xref: /titanic_50/usr/src/lib/libxcurses/src/libc/mks/m_strdup.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
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.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1996, by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  * Copyright 1992 by Mortice Kern Systems Inc.  All rights reserved.
31  *
32  */
33 #ifdef M_RCSID
34 #ifndef lint
35 static char rcsID[] = "$Id: m_strdup.c 1.8 1993/05/28 07:43:26 scott Exp $";
36 #endif
37 #endif
38 
39 #include <mks.h>
40 #include <string.h>
41 #include <stdlib.h>
42 
43 /*f
44  * Return a copy of the string `s', issue an error and return NULL.
45  */
46 LDEFN char *
m_strdup(s)47 m_strdup(s)
48 const char *s;
49 {
50 	char *cp;
51 	int len;
52 
53 	if ((cp = m_malloc(len = strlen(s)+1)) == NULL) {
54 		m_error(m_textmsg(3581, "!memory allocation failure", "E"));
55 		return NULL;
56 	}
57 	return (memcpy(cp, s, len));
58 }
59