1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Return some memory control back to format_and_print_line.

This commit is contained in:
Steven Schubiger 2008-11-12 12:02:37 +01:00
parent fafd83c097
commit 3c1725e7a1
2 changed files with 15 additions and 12 deletions

View File

@ -1,3 +1,8 @@
2008-11-12 Steven Schubiger <stsc@members.fsf.org>
* main.c (print_version): Hand the relevant
xstrdup/xfree calls back to format_and_print_line().
2008-11-11 Steven Schubiger <stsc@members.fsf.org>
* main.c (format_and_print_line): Move both the memory

View File

@ -706,16 +706,18 @@ prompt_for_password (void)
and an appropriate number of spaces are added on subsequent
lines.*/
static void
format_and_print_line (const char *prefix, char *line,
format_and_print_line (const char *prefix, const char *line,
int line_length)
{
int leading_spaces;
int remaining_chars;
char *token;
char *line_dup, *token;
assert (prefix != NULL);
assert (line != NULL);
line_dup = xstrdup (line);
if (line_length <= 0)
line_length = max_chars_per_line;
@ -723,7 +725,7 @@ format_and_print_line (const char *prefix, char *line,
printf ("%s", prefix);
remaining_chars = line_length - leading_spaces;
/* We break on spaces. */
token = strtok (line, " ");
token = strtok (line_dup, " ");
while (token != NULL)
{
/* If however a token is much larger than the maximum
@ -746,6 +748,8 @@ format_and_print_line (const char *prefix, char *line,
}
printf ("\n");
xfree (line_dup);
}
static void
@ -803,23 +807,17 @@ print_version (void)
putchar ('\n');
#endif
line = xstrdup (LOCALEDIR);
format_and_print_line (locale_title,
line,
LOCALEDIR,
max_chars_per_line);
xfree (line);
line = xstrdup (compilation_string);
format_and_print_line (compile_title,
line,
compilation_string,
max_chars_per_line);
xfree (line);
line = xstrdup (link_string);
format_and_print_line (link_title,
line,
link_string,
max_chars_per_line);
xfree (line);
printf ("\n");
/* TRANSLATORS: When available, an actual copyright character