+bool tal_expand_(tal_t **ctxp, const void *src, size_t size, size_t count)
+{
+ size_t old_len;
+ bool ret = false;
+
+ old_len = debug_tal(to_tal_hdr(*ctxp))->bytelen;
+
+ /* Check for additive overflow */
+ if (old_len + count * size < old_len) {
+ call_error("dup size overflow");
+ goto out;
+ }
+
+ /* Don't point src inside thing we're expanding! */
+ assert(src < *ctxp
+ || (char *)src >= (char *)(*ctxp) + old_len);
+
+ if (!tal_resize_(ctxp, size, old_len/size + count, false))
+ goto out;
+
+ memcpy((char *)*ctxp + old_len, src, count * size);
+ ret = true;
+
+out:
+ if (taken(src))
+ tal_free(src);
+ return ret;
+}
+