2 * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
12 SM_RCSID("@(#)$Id: strdup.c,v 1.13 2001/09/11 04:04:49 gshapiro Exp $")
15 #include <sm/string.h>
18 ** SM_STRNDUP_X -- Duplicate a string of a given length
20 ** Allocates memory and copies source string (of given length) into it.
23 ** s -- string to copy.
24 ** n -- length to copy.
27 ** copy of string, raises exception if out of memory.
30 ** allocate memory for new string.
38 char *d = sm_malloc_x(n + 1);
40 (void) memcpy(d, s, n);
46 ** SM_STRDUP -- Duplicate a string
48 ** Allocates memory and copies source string into it.
51 ** s -- string to copy.
54 ** copy of string, NULL if out of memory.
57 ** allocate memory for new string.
68 d = sm_malloc_tagged(l, "sm_strdup", 0, sm_heap_group());
70 (void) sm_strlcpy(d, s, l);