diff options
author | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-09-24 22:38:22 +0000 |
---|---|---|
committer | ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-09-24 22:38:22 +0000 |
commit | 0be2ebc785cd4b366423534d0bfdce0499483e80 (patch) | |
tree | 7ec3b888341991cdf8a157f5d87a6dea617363e5 /libiberty | |
parent | 347e5e07ef4db24f295a4513b381bbb943ddf9f4 (diff) | |
download | gcc-0be2ebc785cd4b366423534d0bfdce0499483e80.tar.gz |
include:
* libiberty.h (reconcat): New function.
libiberty:
* concat.c (reconcat): New function.
gcc:
* c-aux-info.c (affix_data_type): Use ATTRIBUTE_MALLOC. Avoid
leak by passing malloc'ed pointer to reconcat, not concat.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45789 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty')
-rw-r--r-- | libiberty/ChangeLog | 4 | ||||
-rw-r--r-- | libiberty/concat.c | 25 |
2 files changed, 29 insertions, 0 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index b68c4c5b812..1c641169f30 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,7 @@ +2001-09-24 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> + + * concat.c (reconcat): New function. + 2001-09-17 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> * concat.c (vconcat_length, vconcat_copy, concat_length, diff --git a/libiberty/concat.c b/libiberty/concat.c index feed0df819b..136e8be866e 100644 --- a/libiberty/concat.c +++ b/libiberty/concat.c @@ -171,6 +171,31 @@ concat VPARAMS ((const char *first, ...)) return newstr; } +char * +reconcat VPARAMS ((char *optr, const char *first, ...)) +{ + char *newstr; + + /* First compute the size of the result and get sufficient memory. */ + VA_OPEN (args, first); + VA_FIXEDARG (args, char *, optr); + VA_FIXEDARG (args, const char *, first); + newstr = (char *) xmalloc (vconcat_length (first, args) + 1); + VA_CLOSE (args); + + /* Now copy the individual pieces to the result string. */ + VA_OPEN (args, first); + VA_FIXEDARG (args, char *, optr); + VA_FIXEDARG (args, const char *, first); + vconcat_copy (newstr, first, args); + VA_CLOSE (args); + + if (optr) + free (optr); + + return newstr; +} + #ifdef MAIN #define NULLP (char *)0 |