From: Adam Dickmeiss Date: Wed, 26 Jun 2013 12:33:01 +0000 (+0200) Subject: No dupe function (leaks) X-Git-Tag: v1.3.59~44 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=fe752902775deb62f98786bd18b89a6a0edd0d42;p=metaproxy-moved-to-github.git No dupe function (leaks) --- diff --git a/src/html_parser.cpp b/src/html_parser.cpp index 804c2a1..cb1cda5 100644 --- a/src/html_parser.cpp +++ b/src/html_parser.cpp @@ -52,17 +52,6 @@ void mp::HTMLParser::parse(mp::HTMLParserEvent & event, const char *str) const parse_str(event, str); } -//static C functions follow would probably make sense to wrap this in PIMPL? - -static char* dupe(const char *buff, int len) -{ - char *value = (char *) malloc(len + 1); - assert(value); - memcpy(value, buff, len); - value[len] = '\0'; - return value; -} - static int skipSpace(const char *cp) { int i = 0; @@ -135,7 +124,7 @@ static int tagAttrs(mp::HTMLParserEvent & event, i += nor; if (nor) { - DEBUG(printf ("------ attr %s=%s\n", attr_name, dupe(attr_value, val_len))); + DEBUG(printf ("------ attr %s=%.*s\n", attr_name, val_len, attr_value)); event.attribute(tagName, attr_name, attr_value, val_len); } else @@ -193,7 +182,8 @@ static void tagText(mp::HTMLParserEvent & event, const char *text_start, const c { if (text_end - text_start) //got text to flush { - DEBUG(printf("------ text %s\n", dupe(text_start, text_end-text_start))); + DEBUG(printf("------ text %.*s\n", + (int) (text_end - text_start), text_start)); event.text(text_start, text_end-text_start); } }