struct spx_header_info shi;
};
-
-static char *copy_comment(const char *src, int len)
-{
- char *p = para_malloc(len + 1);
-
- if (len > 0)
- memcpy(p, src, len);
- p[len] = '\0';
- PARA_DEBUG_LOG("%s\n", p);
- return p;
-}
-
static bool copy_if_tag_type(const char *tag, int taglen, const char *type,
char **p)
{
- int len = strlen(type);
-
- if (taglen <= len)
- return false;
- if (strncasecmp(tag, type, len))
- return false;
- if (tag[len] != '=')
+ char *q = key_value_copy(tag, taglen, type);
+ if (!q)
return false;
free(*p);
- *p = copy_comment(tag + len + 1, taglen - len - 1);
+ *p = q;
return true;
}
c += 4;
if (c + len > end)
return -E_SPX_COMMENT;
- tags->comment = copy_comment(c, len);
+ tags->comment = safe_strdup(c, len);
c += len;
if (c + 4 > end)
continue;
if (copy_if_tag_type(c, len, "comment", &tags->comment))
continue;
- tag = copy_comment(c, len);
+ tag = safe_strdup(c, len);
PARA_NOTICE_LOG("unrecognized comment: %s\n", tag);
free(tag);
}