...
| Code Block | ||
|---|---|---|
| ||
void f() {
char *copypath = NULL;
/* avoid assuming $PATH is defined or has limited length */
const char *temp = getenv("PATH");
if (temp != NULL) {
path = (char*) malloc(strlen(temp) + 1);
if (copypath == NULL) {
/* Handle error condition */
} else {
strcpy(path, temp);
}
/* use path */
}
}
|
...