Hi Matthew,
Matthew White <[email protected]> writes:
> +void
> +replace_metalink_basename (char **name, char *ref)
> +{
> + size_t dir_len = 0;
> + char *p, *dir, *file, *new;
> +
> + if (!name)
> + return;
> +
> + /* New basename from file name reference. */
> + file = ref;
> + if (file)
> + {
> + p = strrchr (file, '/');
> + if (p)
> + file = p + 1;
> + }
> +
> + /* Old directory. */
> + dir = NULL;
> + if (*name)
> + {
> + p = strrchr (*name, '/');
> + if (p)
> + dir_len = (p - *name) + 1;
> + }
> + dir = xstrndup (*name, dir_len);
I'll review this patch more in details, but one small thing here, could
we modify name in place and avoid a memory allocation for dir?
name[dir_len] = '\0';
Giuseppe