}
void *tal_dup_(const tal_t *ctx, const void *p, size_t size,
- size_t n, size_t extra, const char *label)
+ size_t n, size_t extra, bool nullok, const char *label)
{
void *ret;
size_t nbytes = size;
+ if (nullok && p == NULL) {
+ /* take(NULL) works. */
+ (void)taken(p);
+ return NULL;
+ }
+
if (!adjust_size(&nbytes, n)) {
if (taken(p))
tal_free(p);
return ret;
}
+void *tal_dup_talarr_(const tal_t *ctx, const tal_t *src TAKES, const char *label)
+{
+ return tal_dup_(ctx, src, 1, tal_bytelen(src), 0, true, label);
+}
+
void tal_set_backend(void *(*alloc_fn)(size_t size),
void *(*resize_fn)(void *, size_t size),
void (*free_fn)(void *),
switch (p->type) {
case CHILDREN:
c = (struct children *)p;
- fprintf(stderr, " CHILDREN(%p):parent=%p,children={%p,%p}\n",
+ fprintf(stderr, " CHILDREN(%p):parent=%p,children={%p,%p}",
p, c->parent,
c->children.n.prev, c->children.n.next);
break;