On Mon, Feb 18, 2013 at 10:04:26PM +0100, Goffredo Baroncelli wrote:
> This patch adds some helpers to manage the strings allocation and
> deallocation.
> The function string_list_add(char *) adds the passed string to a list;
> the function string_list_free() frees all the strings together.
Please don't do this. To verify that a given pointer isn't freed before
it's used we'd have to make sure that there are no string_list_free()
calls in the interim that would hit their pointer on this global list.
As far as I can tell, this is only used for the pretty units? Instead
of
printf("%s", leaked_string(raw));
how about
printf("%llu%s", scaled_value(raw), static_unit_str(raw));
That'd avoid the need to pass back arbitrary allocated strings and this
code could go away.
> + if (!strings_to_free) {
> + fprintf(stderr, "add_string_to_free(): Not enough memory\n");
> + strings_to_free = 0;
if (a == 0) a = 0?
> + count_string_to_free = 0;
> + }
> +
> + strings_to_free[count_string_to_free-1] = s;
NULL[-1] = s?
- z
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html