On Tue, Jan 27, 2009 at 07:45:42AM +0000, Jeremy Henty wrote:
On Mon, Jan 26, 2009 at 11:33:43PM +0100, Hofmann Johannes wrote:
There is at least one leak I know of. It's font-family names that are parsed in CSS style data.
Aha! I looked at the Valgrind log for that one but didn't know the cause. Valgrind identifies the dStrdup() in
val->strVal = dStrdup(parser->tval);
in Css_parse_value() as the leak. What's the fix? I thought the problem was that CssPropertyList::set() does not free any existing value but I'm not sure I understand how these classes are meant to manage their memory.
Not 100% sure either :-). The problem only exists for string values. Most CSS values are just enums or lengths. Actually I only know of font names atm that are strings. CSS values are stored in CssProperty::Value, which is a union. The fix is to free Value.strVal, whenever Value contains a strVal (and not an enum or length). To know this we could depend on the corresponding CssProperty::Name (freeing it for CSS_PROPERTY_FONT_FAMILY, but not for others), or add a Type member. The latter is cleaner and would not need more memory, as Name and Type could fit in two shorts. We also need a way to accommodate the special "inherit" value, which is not supported yet. Regards, Johannes