diff options
Diffstat (limited to 'src/lib/libc/string/strdup.c')
-rw-r--r-- | src/lib/libc/string/strdup.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/lib/libc/string/strdup.c b/src/lib/libc/string/strdup.c index 27ede44110..be7f7ad094 100644 --- a/src/lib/libc/string/strdup.c +++ b/src/lib/libc/string/strdup.c | |||
@@ -1,6 +1,8 @@ | |||
1 | /* $OpenBSD: strdup.c,v 1.3 1997/08/20 04:18:52 millert Exp $ */ | ||
2 | |||
1 | /* | 3 | /* |
2 | * Copyright (c) 1988 The Regents of the University of California. | 4 | * Copyright (c) 1988, 1993 |
3 | * All rights reserved. | 5 | * The Regents of the University of California. All rights reserved. |
4 | * | 6 | * |
5 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions |
@@ -32,10 +34,16 @@ | |||
32 | */ | 34 | */ |
33 | 35 | ||
34 | #if defined(LIBC_SCCS) && !defined(lint) | 36 | #if defined(LIBC_SCCS) && !defined(lint) |
35 | /*static char *sccsid = "from: @(#)strdup.c 5.4 (Berkeley) 2/24/91";*/ | 37 | #if 0 |
36 | static char *rcsid = "$Id: strdup.c,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $"; | 38 | static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93"; |
39 | #else | ||
40 | static char *rcsid = "$OpenBSD: strdup.c,v 1.3 1997/08/20 04:18:52 millert Exp $"; | ||
41 | #endif | ||
37 | #endif /* LIBC_SCCS and not lint */ | 42 | #endif /* LIBC_SCCS and not lint */ |
38 | 43 | ||
44 | #include <sys/types.h> | ||
45 | |||
46 | #include <stddef.h> | ||
39 | #include <stdlib.h> | 47 | #include <stdlib.h> |
40 | #include <string.h> | 48 | #include <string.h> |
41 | 49 | ||
@@ -43,12 +51,12 @@ char * | |||
43 | strdup(str) | 51 | strdup(str) |
44 | const char *str; | 52 | const char *str; |
45 | { | 53 | { |
46 | size_t len; | 54 | size_t siz; |
47 | char *copy; | 55 | char *copy; |
48 | 56 | ||
49 | len = strlen(str) + 1; | 57 | siz = strlen(str) + 1; |
50 | if (!(copy = malloc(len))) | 58 | if ((copy = malloc(siz)) == NULL) |
51 | return((char *)NULL); | 59 | return(NULL); |
52 | memcpy(copy, str, len); | 60 | (void)memcpy(copy, str, siz); |
53 | return(copy); | 61 | return(copy); |
54 | } | 62 | } |