On March 18, 2016 6:16:46 AM GMT+01:00, Hongxu Jia <hongxu....@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,