]> code.delx.au - pulseaudio/blob - src/client.c
initial commit
[pulseaudio] / src / client.c
1 #include <assert.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5 #include "client.h"
6
7 struct client *client_new(struct core *core, const char *protocol_name, char *name) {
8 struct client *c;
9 int r;
10 assert(core);
11
12 c = malloc(sizeof(struct client));
13 assert(c);
14 c->protocol_name = protocol_name;
15 c->name = name ? strdup(name) : NULL;
16 c->kill = NULL;
17 c->userdata = NULL;
18 c->core = core;
19
20 r = idxset_put(core->clients, c, &c->index);
21 assert(c->index != IDXSET_INVALID && r >= 0);
22
23 return c;
24 }
25
26 void client_free(struct client *c) {
27 assert(c && c->core);
28
29 idxset_remove_by_data(c->core->clients, c, NULL);
30 free(c->name);
31 free(c);
32 }