Remove mass calloc() on memcached_st creation.
[m6w6/libmemcached] / libmemcached / verbosity.c
1 #include "common.h"
2
3 memcached_return_t memcached_verbosity(memcached_st *ptr, uint32_t verbosity)
4 {
5 uint32_t x;
6 size_t send_length;
7 memcached_return_t rc;
8 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
9
10 send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
11 "verbosity %u\r\n", verbosity);
12 unlikely (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
13 return MEMCACHED_WRITE_FAILURE;
14
15 rc= MEMCACHED_SUCCESS;
16 for (x= 0; x < memcached_server_count(ptr); x++)
17 {
18 memcached_return_t rrc;
19 memcached_server_instance_st *instance=
20 memcached_server_instance_fetch(ptr, x);
21
22 rrc= memcached_do(instance, buffer, send_length, 1);
23 if (rrc != MEMCACHED_SUCCESS)
24 {
25 rc= MEMCACHED_SOME_ERRORS;
26 continue;
27 }
28
29 unlikely (ptr->flags.use_udp)
30 continue;
31
32 rrc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
33 if (rrc != MEMCACHED_SUCCESS)
34 rc= MEMCACHED_SOME_ERRORS;
35 }
36
37 return rc;
38 }