示例#1
0
t_net_client	*net_client_create(void)
{
	t_net_client	*client;

	if (!(client = malloc(sizeof(*client))))
		return (NULL);
	if (!(client->rbuffer = net_buffer_create()))
	{
		free(client);
		return (NULL);
	}
	if (!(client->wbuffer = net_buffer_create()))
	{
		free(client->rbuffer);
		free(client);
		return (NULL);
	}
	return (client);
}
示例#2
0
struct net_buffer_t *net_node_add_output_buffer(struct net_node_t *node,
	int bandwidth)
{
	struct net_buffer_t *buffer;
	char name[MAX_STRING_SIZE];

	snprintf(name, sizeof(name), "out_buf_%d",
		list_count(node->output_buffer_list));
	buffer = net_buffer_create(node->net, node, bandwidth, name);
	buffer->index = list_count(node->output_buffer_list);
	list_add(node->output_buffer_list, buffer);
	return buffer;
}