On Fri, 2013-04-05 at 12:33 +0300, Jukka Rissanen wrote:
> + client = g_hash_table_lookup(partial_tcp_req_table,
> + GINT_TO_POINTER(client_sk));
> + if (client == NULL) {
> + client = g_try_new0(struct tcp_partial_client_data,
> 1);
> + if (client == NULL)
> + return FALSE;
> +
> + g_hash_table_insert(partial_tcp_req_table,
> + GINT_TO_POINTER(client_sk),
> + client);
> +
> + client->channel = g_io_channel_unix_new(client_sk);
> + g_io_channel_set_close_on_unref(client->channel,
> TRUE);
> +
> + client->watch = g_io_add_watch(client->channel,
> + G_IO_IN,
> tcp_client_event,
> + (gpointer)client);
> +
> + client->ifdata = ifdata;
> +
> + DBG("client %d created %p", client_sk, client);
> + } else {
> + DBG("client %d already exists %p", client_sk, client);
> + }
> +
> + if (client->buf == NULL) {
> + client->buf = g_try_malloc(TCP_MAX_BUF_LEN);
> + if (client->buf == NULL)
> + return FALSE;
> + }
Should the buffer be allocated in the 'if (client == NULL)' branch with
the rest of the struct? Can the struct contain the 4k buffer itself, as
it seems it's a mandatory component of the structure? What happens to
the client struct if we return FALSE here?
Cheers,
Patrik
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman