2 * Copyright (C) 2006-2010 Brian Aker
5 * Use and distribution licensed under the BSD license. See
6 * the COPYING file in the parent directory for full text.
15 memcached_server_list_st
16 memcached_server_list_append_with_weight(memcached_server_list_st ptr
,
17 const char *hostname
, in_port_t port
,
19 memcached_return_t
*error
)
22 memcached_server_list_st new_host_list
;
24 if (hostname
== NULL
|| error
== NULL
)
27 if (hostname
[0] == '/')
30 port
= MEMCACHED_DEFAULT_PORT
;
32 /* Increment count for hosts */
36 count
+= memcached_server_list_count(ptr
);
39 new_host_list
= (memcached_server_write_instance_st
)realloc(ptr
, sizeof(memcached_server_st
) * count
);
42 ptr
->cached_errno
= errno
;
43 *error
= MEMCACHED_MEMORY_ALLOCATION_FAILURE
;
47 /* @todo Check return type */
48 memcached_server_create_with(NULL
, &new_host_list
[count
-1], hostname
, port
, weight
, port
? MEMCACHED_CONNECTION_TCP
: MEMCACHED_CONNECTION_UNIX_SOCKET
);
50 // Handset allocated since
51 new_host_list
->options
.is_allocated
= true;
53 /* Backwards compatibility hack */
54 memcached_servers_set_count(new_host_list
, count
);
56 *error
= MEMCACHED_SUCCESS
;
60 memcached_server_list_st
61 memcached_server_list_append(memcached_server_list_st ptr
,
62 const char *hostname
, in_port_t port
,
63 memcached_return_t
*error
)
65 return memcached_server_list_append_with_weight(ptr
, hostname
, port
, 0, error
);
68 uint32_t memcached_server_list_count(const memcached_server_list_st self
)
72 : self
->number_of_hosts
;
75 memcached_server_st
*memcached_server_list(const memcached_st
*self
)
80 void memcached_server_list_set(memcached_st
*self
, memcached_server_st
*list
)