diff options
author | harti <harti@FreeBSD.org> | 2004-12-08 08:11:59 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2004-12-08 08:11:59 +0000 |
commit | bde7bbf9ad62c24bcf5c8ca7fc0423db69e01699 (patch) | |
tree | a7ee9927fa2e9d0ed7221a08d2ef7ecdf58e3840 | |
parent | 979de51e35ba33e737fc2b53a531376af247283d (diff) | |
download | FreeBSD-src-bde7bbf9ad62c24bcf5c8ca7fc0423db69e01699.zip FreeBSD-src-bde7bbf9ad62c24bcf5c8ca7fc0423db69e01699.tar.gz |
Consify the arguments to str_concat. Remove the STR_DOFREE flag for that
purpose and explicitely free the input string in the one place that was
calling str_concat with that flag.
Submitted by: Max Okumoto <okumoto@ucsd.edu>
-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 b9cfbdf..861da59 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 b23006f..bd894bd 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 132879d..c622d4b 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 a05d09e..7a1dd6c 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); } |