From: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
To: Hongxu Jia <hongxu.jia@windriver.com>,Joseph Myers
<joseph@codesourcery.com>
Cc: jakub@gcc.gnu.org,rguenth@gcc.gnu.org,gcc-patches@gcc.gnu.org,richard.purdie@linuxfoundation.org
Subject: Re: [PATCH V3]PR other/70268: map one directory name (old) to another (new) in __FILE__
Date: Fri, 18 Mar 2016 08:05:00 -0000 [thread overview]
Message-ID: <97BE5D73-0EDD-43ED-9B71-FB477D7E2701@gmail.com> (raw)
In-Reply-To: <56EB8F3E.90901@windriver.com>
On March 18, 2016 6:16:46 AM GMT+01:00, Hongxu Jia <hongxu.jia@windriver.com> wrote:
+/* Perform user-specified mapping of __FILE__ prefixes. Return
+ the new name corresponding to filename. */
+
+const char *
+remap_file_filename (const char *filename)
+{
+ file_prefix_map *map;
+ char *s;
+ const char *name;
+ size_t name_len;
+
+ for (map = file_prefix_maps; map; map = map->next)
+ if (filename_ncmp (filename, map->old_prefix, map->old_len) == 0)
+ break;
+ if (!map)
+ return filename;
+ name = filename + map->old_len;
+ name_len = strlen (name) + 1;
+ s = (char *) alloca (name_len + map->new_len);
+ memcpy (s, map->new_prefix, map->new_len);
+ memcpy (s + map->new_len, name, name_len);
+
+ return xstrdup (s);
+}
Please explain why you first alloca() and then strdup the result instead of XNEWVEC
Thanks,
next prev parent reply other threads:[~2016-03-18 7:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-17 8:57 [PATCH]PR " Hongxu Jia
2016-03-17 9:54 ` [PATCH V2]PR " Hongxu Jia
2016-03-17 22:47 ` [PATCH]PR " Joseph Myers
2016-03-18 2:30 ` Hongxu Jia
2016-03-18 7:56 ` [PATCH V3]PR " Hongxu Jia
2016-03-18 8:05 ` Bernhard Reutner-Fischer [this message]
2016-03-18 8:11 ` Hongxu Jia
2016-03-18 9:36 ` Hongxu Jia
2016-03-23 7:49 ` Hongxu Jia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=97BE5D73-0EDD-43ED-9B71-FB477D7E2701@gmail.com \
--to=rep.dot.nop@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hongxu.jia@windriver.com \
--cc=jakub@gcc.gnu.org \
--cc=joseph@codesourcery.com \
--cc=rguenth@gcc.gnu.org \
--cc=richard.purdie@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).