summaryrefslogtreecommitdiff
path: root/src/lib/libc/string/strdup.c
diff options
context:
space:
mode:
authormillert <>1997-08-20 04:18:52 +0000
committermillert <>1997-08-20 04:18:52 +0000
commit4faa3305b950b8ac8eaa6c02f8d7099f2e0f623d (patch)
tree491119cbafe91e0b3d6f6b0d329dfe76a07e68e0 /src/lib/libc/string/strdup.c
parenteefd83616fed7208460c4c742ea85c68488acf7c (diff)
downloadopenbsd-4faa3305b950b8ac8eaa6c02f8d7099f2e0f623d.tar.gz
openbsd-4faa3305b950b8ac8eaa6c02f8d7099f2e0f623d.tar.bz2
openbsd-4faa3305b950b8ac8eaa6c02f8d7099f2e0f623d.zip
Update man page and sccs tags from lite2. Minor cleanup by me as well.
Diffstat (limited to 'src/lib/libc/string/strdup.c')
-rw-r--r--src/lib/libc/string/strdup.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/lib/libc/string/strdup.c b/src/lib/libc/string/strdup.c
index 74c462d241..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,9 +34,16 @@
32 */ 34 */
33 35
34#if defined(LIBC_SCCS) && !defined(lint) 36#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: strdup.c,v 1.2 1996/08/19 08:34:16 tholo Exp $"; 37#if 0
38static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93";
39#else
40static char *rcsid = "$OpenBSD: strdup.c,v 1.3 1997/08/20 04:18:52 millert Exp $";
41#endif
36#endif /* LIBC_SCCS and not lint */ 42#endif /* LIBC_SCCS and not lint */
37 43
44#include <sys/types.h>
45
46#include <stddef.h>
38#include <stdlib.h> 47#include <stdlib.h>
39#include <string.h> 48#include <string.h>
40 49
@@ -42,12 +51,12 @@ char *
42strdup(str) 51strdup(str)
43 const char *str; 52 const char *str;
44{ 53{
45 size_t len; 54 size_t siz;
46 char *copy; 55 char *copy;
47 56
48 len = strlen(str) + 1; 57 siz = strlen(str) + 1;
49 if (!(copy = malloc(len))) 58 if ((copy = malloc(siz)) == NULL)
50 return((char *)NULL); 59 return(NULL);
51 memcpy(copy, str, len); 60 (void)memcpy(copy, str, siz);
52 return(copy); 61 return(copy);
53} 62}