[Parted-commits] GNU Parted Official Repository: Changes to 'master'
Jim Meyering
meyering at alioth.debian.org
Fri May 25 16:45:53 UTC 2007
parted/strlist.c | 22 ++--------------------
1 file changed, 2 insertions(+), 20 deletions(-)
New commits:
commit c6b1b351b432c227157d8da6e99388958b07115a
Author: Jim Meyering <jim at meyering.net>
Date: Fri May 25 18:45:39 2007 +0200
Remove a silly (and dangerous) function.
This change has no effect, except in a low-memory condition,
where the old code would dereference NULL, the new code no
longer performs that malloc.
* parted/strlist.c (get_spaces): Remove this function.
Not only is it useless, but it also has an unchecked malloc.
(str_list_print_wrap): Don't allocate and initialize a string
just to print a sequence of N spaces.
diff --git a/parted/strlist.c b/parted/strlist.c
index da1b09f..b5d2ba4 100644
--- a/parted/strlist.c
+++ b/parted/strlist.c
@@ -1,6 +1,6 @@
/*
parted - a frontend to libparted
- Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2007 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -390,20 +390,6 @@ str_list_print (const StrList* list)
}
}
-static char*
-get_spaces (int space_count)
-{
- char* str;
- int i;
-
- str = malloc (space_count + 1);
- for (i = 0; i < space_count; i++)
- str [i] = ' ';
- str [i] = 0;
-
- return str;
-}
-
static int
str_search (const wchar_t* str, int n, wchar_t c)
{
@@ -459,13 +445,11 @@ str_list_print_wrap (const StrList* list, int line_length, int offset,
int cut_right;
int cut_left;
int line_left;
- char* spaces;
int search_result;
int line_break;
PED_ASSERT (line_length - indent > 10, return);
- spaces = get_spaces (indent);
line_left = line_length - offset;
for (walk=list; walk; walk=walk->next) {
@@ -511,7 +495,7 @@ str_list_print_wrap (const StrList* list, int line_length, int offset,
line_left = line_length - indent;
if (walk->next || *str)
- printf ("\n%s", spaces);
+ printf ("\n%*s", indent, " ");
else if (line_break)
putchar ('\n');
}
@@ -519,8 +503,6 @@ str_list_print_wrap (const StrList* list, int line_length, int offset,
print_wchar (str, 0);
line_left -= wchar_strlen (str);
}
-
- free (spaces);
}
static int
More information about the Parted-commits
mailing list