Changeset View
Changeset View
Standalone View
Standalone View
stand/libsa/strdup.c
Show All 33 Lines | |||||
static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93"; | static char sccsid[] = "@(#)strdup.c 8.1 (Berkeley) 6/4/93"; | ||||
#endif /* LIBC_SCCS and not lint */ | #endif /* LIBC_SCCS and not lint */ | ||||
#include "stand.h" | #include "stand.h" | ||||
#include <stddef.h> | #include <stddef.h> | ||||
#include <string.h> | #include <string.h> | ||||
char * | char * | ||||
strdup(str) | strdup(const char *str) | ||||
const char *str; | |||||
{ | { | ||||
size_t len; | |||||
char *copy = NULL; | char *copy = NULL; | ||||
size_t len; | |||||
if (str != NULL) { | if (str != NULL) { | ||||
len = strlen(str) + 1; | len = strlen(str) + 1; | ||||
if ((copy = malloc(len)) == NULL) | if ((copy = (char *)malloc(len)) != NULL) | ||||
jrtc27: You don't need this cast | |||||
return (NULL); | |||||
memcpy(copy, str, len); | memcpy(copy, str, len); | ||||
Done Inline Actionsstyle(9) has all variables declared at the start of the function, with the sole exception being that for loops may declare their counter variable jrtc27: style(9) has all variables declared at the start of the function, with the sole exception being… | |||||
} | } | ||||
return (copy); | return (copy); | ||||
} | } |
You don't need this cast