handle allocation failures some more

This commit is contained in:
Wim Taymans 2017-11-20 16:03:45 +01:00
parent 5bebfe022b
commit 2ad722b579
7 changed files with 18 additions and 6 deletions

View file

@ -146,7 +146,8 @@ void pw_client_register(struct pw_client *client,
spa_list_append(&core->client_list, &client->link); spa_list_append(&core->client_list, &client->link);
client->global = pw_core_add_global(core, owner, parent, core->type.client, PW_VERSION_CLIENT, client->global = pw_core_add_global(core, owner, parent, core->type.client, PW_VERSION_CLIENT,
client_bind_func, client); client_bind_func, client);
client->info.id = client->global->id; if (client->global != NULL)
client->info.id = client->global->id;
} }
struct pw_core *pw_client_get_core(struct pw_client *client) struct pw_core *pw_client_get_core(struct pw_client *client)

View file

@ -465,7 +465,8 @@ struct pw_core *pw_core_new(struct pw_loop *main_loop, struct pw_properties *pro
PW_VERSION_CORE, PW_VERSION_CORE,
core_bind_func, core_bind_func,
this); this);
this->info.id = this->global->id; if (this->global != NULL)
this->info.id = this->global->id;
return this; return this;

View file

@ -124,6 +124,8 @@ void pw_factory_register(struct pw_factory *factory,
spa_list_append(&core->factory_list, &factory->link); spa_list_append(&core->factory_list, &factory->link);
factory->global = pw_core_add_global(core, owner, parent, factory->global = pw_core_add_global(core, owner, parent,
core->type.factory, 0, factory_bind_func, factory); core->type.factory, 0, factory_bind_func, factory);
if (factory->global != NULL)
factory->info.id = factory->global->id;
} }
void *pw_factory_get_user_data(struct pw_factory *factory) void *pw_factory_get_user_data(struct pw_factory *factory)

View file

@ -1221,9 +1221,11 @@ void pw_link_register(struct pw_link *link,
struct pw_node *input_node, *output_node; struct pw_node *input_node, *output_node;
spa_list_append(&core->link_list, &link->link); spa_list_append(&core->link_list, &link->link);
link->global = pw_core_add_global(core, owner, parent, core->type.link, PW_VERSION_LINK, link->global = pw_core_add_global(core, owner, parent, core->type.link, PW_VERSION_LINK,
link_bind_func, link); link_bind_func, link);
link->info.id = link->global->id; if (link->global != NULL)
link->info.id = link->global->id;
input_node = link->input->node; input_node = link->input->node;
output_node = link->output->node; output_node = link->output->node;

View file

@ -222,7 +222,8 @@ struct pw_module *pw_module_load(struct pw_core *core, const char *name, const c
core->type.module, PW_VERSION_MODULE, core->type.module, PW_VERSION_MODULE,
module_bind_func, this); module_bind_func, this);
this->info.id = this->global->id; if (this->global != NULL)
this->info.id = this->global->id;
if (!init_func(this, args)) if (!init_func(this, args))
goto init_failed; goto init_failed;
@ -273,7 +274,8 @@ void pw_module_destroy(struct pw_module *module)
free((char *) module->info.args); free((char *) module->info.args);
spa_list_remove(&module->link); spa_list_remove(&module->link);
pw_global_destroy(module->global); if (module->global)
pw_global_destroy(module->global);
dlclose(impl->hnd); dlclose(impl->hnd);
free(impl); free(impl);
} }

View file

@ -358,8 +358,9 @@ void pw_node_register(struct pw_node *this,
this->global = pw_core_add_global(core, owner, parent, this->global = pw_core_add_global(core, owner, parent,
core->type.node, PW_VERSION_NODE, core->type.node, PW_VERSION_NODE,
node_bind_func, this); node_bind_func, this);
if (this->global != NULL)
this->info.id = this->global->id;
this->info.id = this->global->id;
spa_hook_list_call(&this->listener_list, struct pw_node_events, initialized); spa_hook_list_call(&this->listener_list, struct pw_node_events, initialized);
pw_node_update_state(this, PW_NODE_STATE_SUSPENDED, NULL); pw_node_update_state(this, PW_NODE_STATE_SUSPENDED, NULL);

View file

@ -39,6 +39,9 @@ struct pw_protocol *pw_protocol_new(struct pw_core *core,
struct pw_protocol *protocol; struct pw_protocol *protocol;
protocol = calloc(1, sizeof(struct impl) + user_data_size); protocol = calloc(1, sizeof(struct impl) + user_data_size);
if (protocol == NULL)
return NULL;
protocol->core = core; protocol->core = core;
protocol->name = strdup(name); protocol->name = strdup(name);