pipewire: allow NULL pointers in pw_memmap_free()

Just like the real free() we should just ignore a NULL pointer, makes the
caller code easier for those instances where properties are optional.
This commit is contained in:
Peter Hutterer 2021-06-02 15:24:08 +10:00 committed by Wim Taymans
parent 71e0cfb5fa
commit 1d4b24d02b
4 changed files with 18 additions and 16 deletions

View file

@ -1472,8 +1472,7 @@ static int client_node_set_io(void *object,
default:
break;
}
if (old != NULL)
pw_memmap_free(old);
pw_memmap_free(old);
return 0;
}
@ -2085,8 +2084,7 @@ static int client_node_port_set_io(void *object,
break;
}
exit_free:
if (old != NULL)
pw_memmap_free(old);
pw_memmap_free(old);
exit:
if (res < 0)
pw_proxy_error((struct pw_proxy*)c->node, res, spa_strerror(res));

View file

@ -386,8 +386,7 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
memid = SPA_ID_INVALID;
mem_offset = mem_size = 0;
}
if (old != NULL)
pw_memmap_free(old);
pw_memmap_free(old);
if (this->resource == NULL)
return data == NULL ? 0 : -EIO;
@ -706,8 +705,7 @@ static int do_port_set_io(struct impl *impl,
memid = SPA_ID_INVALID;
mem_offset = mem_size = 0;
}
if (old != NULL)
pw_memmap_free(old);
pw_memmap_free(old);
if (this->resource == NULL)
return data == NULL ? 0 : -EIO;

View file

@ -457,8 +457,7 @@ client_node_set_io(void *object,
res = spa_node_set_io(data->node->node, id, ptr, size);
if (old != NULL)
pw_memmap_free(old);
pw_memmap_free(old);
exit:
if (res < 0) {
pw_log_error("node %p: set_io: %s", proxy, spa_strerror(res));
@ -809,8 +808,7 @@ client_node_port_set_io(void *object,
activate_mix(data, mix);
}
exit_free:
if (old != NULL)
pw_memmap_free(old);
pw_memmap_free(old);
exit:
if (res < 0) {
pw_log_error("port %p: set_io: %s", mix, spa_strerror(res));

View file

@ -424,10 +424,18 @@ struct pw_memmap * pw_mempool_map_id(struct pw_mempool *pool,
SPA_EXPORT
int pw_memmap_free(struct pw_memmap *map)
{
struct memmap *mm = SPA_CONTAINER_OF(map, struct memmap, this);
struct mapping *m = mm->mapping;
struct memblock *b = m->block;
struct mempool *p = SPA_CONTAINER_OF(b->this.pool, struct mempool, this);
struct memmap *mm;
struct mapping *m;
struct memblock *b;
struct mempool *p;
if (map == NULL)
return 0;
mm = SPA_CONTAINER_OF(map, struct memmap, this);
m = mm->mapping;
b = m->block;
p = SPA_CONTAINER_OF(b->this.pool, struct mempool, this);
pw_log_debug(NAME" %p: map:%p block:%p fd:%d ptr:%p mapping:%p ref:%d", p,
&mm->this, b, b->this.fd, mm->this.ptr, m, m->ref);