diff options
| author | Hartmut Brandt <harti@FreeBSD.org> | 2004-12-08 08:11:59 +0000 |
|---|---|---|
| committer | Hartmut Brandt <harti@FreeBSD.org> | 2004-12-08 08:11:59 +0000 |
| commit | cb93e26c8adcb43f291c657987a73b1f20f37cd7 (patch) | |
| tree | a7ee9927fa2e9d0ed7221a08d2ef7ecdf58e3840 /usr.bin | |
| parent | 9f73f0e89792bf7f4f188cdf99bd598dfc670d4a (diff) | |
Notes
Diffstat (limited to 'usr.bin')
| -rw-r--r-- | usr.bin/make/dir.c | 6 | ||||
| -rw-r--r-- | usr.bin/make/make.h | 5 | ||||
| -rw-r--r-- | usr.bin/make/nonints.h | 2 | ||||
| -rw-r--r-- | usr.bin/make/str.c | 10 |
4 files changed, 9 insertions, 14 deletions
diff --git a/usr.bin/make/dir.c b/usr.bin/make/dir.c index b9cfbdfaf64ee..861da594328b0 100644 --- a/usr.bin/make/dir.c +++ b/usr.bin/make/dir.c @@ -1115,6 +1115,7 @@ Dir_MakeFlags(char *flag, Lst *path) { char *str; /* the string which will be returned */ char *tstr; /* the current directory preceded by 'flag' */ + char *nstr; LstNode *ln; /* the node of the current directory */ Path *p; /* the structure describing the current directory */ @@ -1124,7 +1125,10 @@ Dir_MakeFlags(char *flag, Lst *path) while ((ln = Lst_Next(path)) != NULL) { p = Lst_Datum(ln); tstr = str_concat(flag, p->name, 0); - str = str_concat(str, tstr, STR_ADDSPACE | STR_DOFREE); + nstr = str_concat(str, tstr, STR_ADDSPACE); + free(str); + free(tstr); + str = nstr; } Lst_Close(path); } diff --git a/usr.bin/make/make.h b/usr.bin/make/make.h index b23006f4f28a6..bd894bdaafa4b 100644 --- a/usr.bin/make/make.h +++ b/usr.bin/make/make.h @@ -239,12 +239,9 @@ typedef struct IFile { * final string should look. If STR_ADDSPACE is given, a space will be * placed between the two strings. If STR_ADDSLASH is given, a '/' will * be used instead of a space. If neither is given, no intervening characters - * will be placed between the two strings in the final output. If the - * STR_DOFREE bit is set, the two input strings will be freed before - * Str_Concat returns. + * will be placed between the two strings in the final output. */ #define STR_ADDSPACE 0x01 /* add a space when Str_Concat'ing */ -#define STR_DOFREE 0x02 /* free source strings after concatenation */ #define STR_ADDSLASH 0x04 /* add a slash when Str_Concat'ing */ /* diff --git a/usr.bin/make/nonints.h b/usr.bin/make/nonints.h index 132879d1b68c5..c622d4ba69071 100644 --- a/usr.bin/make/nonints.h +++ b/usr.bin/make/nonints.h @@ -93,7 +93,7 @@ Lst *Parse_MainName(void); /* str.c */ void str_init(void); void str_end(void); -char *str_concat(char *, char *, int); +char *str_concat(const char *, const char *, int); char **brk_string(char *, int *, Boolean); int Str_Match(const char *, const char *); const char *Str_SYSVMatch(const char *, const char *, int *); diff --git a/usr.bin/make/str.c b/usr.bin/make/str.c index a05d09ec5b5c2..7a1dd6cf1191d 100644 --- a/usr.bin/make/str.c +++ b/usr.bin/make/str.c @@ -80,14 +80,13 @@ str_end(void) /*- * str_concat -- - * concatenate the two strings, inserting a space or slash between them, - * freeing them if requested. + * concatenate the two strings, inserting a space or slash between them. * * returns -- * the resulting string in allocated space. */ char * -str_concat(char *s1, char *s2, int flags) +str_concat(const char *s1, const char *s2, int flags) { int len1, len2; char *result; @@ -114,11 +113,6 @@ str_concat(char *s1, char *s2, int flags) /* copy second string plus EOS into place */ memcpy(result + len1, s2, len2 + 1); - /* free original strings */ - if (flags & STR_DOFREE) { - free(s1); - free(s2); - } return (result); } |
