int lxc_add_state_client(int state_client_fd, struct lxc_handler *handler,
lxc_state_t states[MAX_STATE])
{
+ __do_free struct lxc_state_client *newclient = NULL;
+ __do_free struct lxc_list *tmplist = NULL;
int state;
- struct lxc_state_client *newclient;
- struct lxc_list *tmplist;
newclient = malloc(sizeof(*newclient));
if (!newclient)
newclient->clientfd = state_client_fd;
tmplist = malloc(sizeof(*tmplist));
- if (!tmplist) {
- free(newclient);
+ if (!tmplist)
return -ENOMEM;
- }
state = handler->state;
if (states[state] != 1) {
lxc_list_add_elem(tmplist, newclient);
lxc_list_add_tail(&handler->conf->state_clients, tmplist);
} else {
- free(newclient);
- free(tmplist);
return state;
}
TRACE("Added state client %d to state client list", state_client_fd);
+ move_ptr(newclient);
+ move_ptr(tmplist);
return MAX_STATE;
}