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_st
*memcached_server_list_append_with_weight(memcached_server_st
*ptr
,
16 const char *hostname
, in_port_t port
,
18 memcached_return_t
*error
)
21 memcached_server_instance_st
*new_host_list
;
23 if (hostname
== NULL
|| error
== NULL
)
27 port
= MEMCACHED_DEFAULT_PORT
;
29 /* Increment count for hosts */
33 count
+= memcached_servers_count(ptr
);
36 new_host_list
= (memcached_server_instance_st
*)realloc(ptr
, sizeof(memcached_server_instance_st
) * count
);
39 *error
= MEMCACHED_MEMORY_ALLOCATION_FAILURE
;
43 /* TODO: Check return type */
44 memcached_server_create_with(NULL
, &new_host_list
[count
-1], hostname
, port
, weight
, MEMCACHED_CONNECTION_TCP
);
46 /* Backwards compatibility hack */
47 memcached_servers_set_count(new_host_list
, count
);
49 *error
= MEMCACHED_SUCCESS
;
53 memcached_server_st
*memcached_server_list_append(memcached_server_st
*ptr
,
54 const char *hostname
, in_port_t port
,
55 memcached_return_t
*error
)
57 return memcached_server_list_append_with_weight(ptr
, hostname
, port
, 0, error
);