A buffer variable wasn't dereferenced in two similar comparisons in ResList
[AROS.git] / compiler / alib / strdup.c
blob1486ddd0d98ee78b627e8777518bc2351c412959
1 /*
2 Copyright © 2002-2003, The AROS Development Team. All rights reserved.
3 $Id$
5 AllocVec-based string duplication.
6 */
8 #include "alib_intern.h"
9 #include <exec/memory.h>
10 #include <string.h>
12 /*****************************************************************************
14 NAME */
15 #define NO_INLINE_STDARG /* turn off inline def */
16 #include <proto/exec.h>
18 STRPTR StrDup (
20 /* SYNOPSIS */
21 CONST_STRPTR str)
23 /* FUNCTION
24 This function allocates enough space, and copies the given string
25 into it.
27 INPUTS
28 str - the string to duplicate
30 RESULT
31 A string copy of the original string (possibly of zero length) or
32 NULL if passed a NULL pointer.
34 NOTES
35 This functions allocates the new string memory with AllocVec().
36 Don't forget to call FreeVec() when you're done with it.
38 EXAMPLE
40 BUGS
42 SEE ALSO
43 exec.library/AllocVec(), exec.library/FreeVec(), exec.library/CopyMem()
45 INTERNALS
47 *****************************************************************************/
49 STRPTR dup;
50 ULONG len;
52 if (str == NULL) return NULL;
54 len = strlen(str);
55 dup = AllocVec(len + 1, MEMF_PUBLIC);
56 if (dup != NULL) CopyMem(str, dup, len + 1);
58 return dup;
60 } /* StrDup */