Change hosts over to realloc array
[awesomized/libmemcached] / lib / memcached_delete.c
1 #include <memcached.h>
2
3 memcached_return memcached_delete(memcached_st *ptr, char *key, size_t key_length,
4 time_t expiration)
5 {
6 size_t send_length;
7 memcached_return rc;
8 char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
9
10 rc= memcached_connect(ptr);
11
12 if (expiration)
13 send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
14 "delete %.*s %u\r\n", key_length, key, expiration);
15 else
16 send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
17 "delete %.*s\r\n", key_length, key);
18 if ((write(ptr->hosts[0].fd, buffer, send_length) == -1))
19 {
20 fprintf(stderr, "failed set on %.*s TCP\n", key_length+1, key);
21
22 return MEMCACHED_WRITE_FAILURE;
23 }
24
25 return memcached_response(ptr, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE);
26 }