buf->max_len = max_len;
buf->raw_len = max_len * LIZARD_MAX_MULTIPLY + LIZARD_MAX_ADD + MAX_HEADER_SIZE;
buf->raw = xmalloc(buf->raw_len);
- buf->lizard = lizard_alloc(max_len);
-}
-
-static void
-buck2obj_free_internal(struct buck2obj_buf *buf)
-{
- lizard_free(buf->lizard);
- xfree(buf->raw);
}
struct buck2obj_buf *
{
struct buck2obj_buf *buf = xmalloc(sizeof(struct buck2obj_buf));
buck2obj_alloc_internal(buf, max_len);
+ buf->lizard = lizard_alloc(max_len);
buf->mp = mp;
return buf;
}
void
buck2obj_free(struct buck2obj_buf *buf)
{
- buck2obj_free_internal(buf);
+ lizard_free(buf->lizard);
+ xfree(buf->raw);
xfree(buf);
}
return;
if (max_len < 2*buf->max_len + 1) // to ensure amortized logarithmic complexity
max_len = 2*buf->max_len + 1;
- buck2obj_free_internal(buf);
+ xfree(buf->raw);
buck2obj_alloc_internal(buf, max_len);
+ lizard_realloc(buf->lizard, max_len);
}
static inline byte *