rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);
- if (rc == MEMCACHED_SUCCESS)
+ if (rc != MEMCACHED_SUCCESS)
{
- return MEMCACHED_SUCCESS;
+ return memcached_set_error(*instance, rc, MEMCACHED_AT);
}
/*
cache_constructor_t* constructor,
cache_destructor_t* destructor) {
cache_t* ret = calloc(1, sizeof(cache_t));
- char* nm = strdup(name);
+ size_t name_length= strlen(name);
+ char* nm= calloc(1, (sizeof(char) * name_length) +1);
+ memcpy(nm, name, name_length);
void** ptr = calloc(initial_pool_size, bufsize);
if (ret == NULL || nm == NULL || ptr == NULL ||
pthread_mutex_init(&ret->mutex, NULL) == -1) {
#include <netdb.h>
#endif
+#ifdef NI_MAXHOST
+#define MEMCACHED_NI_MAXHOST NI_MAXHOST
+#else
+#define MEMCACHED_NI_MAXHOST 1025
+#endif
+
enum memcached_server_state_t {
MEMCACHED_SERVER_STATE_NEW, // fd == -1, no address lookup has been done
MEMCACHED_SERVER_STATE_ADDRINFO, // ADDRRESS information has been gathered
struct memcached_error_t *error_messages;
char read_buffer[MEMCACHED_MAX_BUFFER];
char write_buffer[MEMCACHED_MAX_BUFFER];
- char hostname[NI_MAXHOST];
+ char hostname[MEMCACHED_NI_MAXHOST];
};
test_zero(string_length);
test_false(string);
}
- test_compare(before_query_id, memcached_query_id(memc_clone) +1);
+ test_compare(before_query_id +1, memcached_query_id(memc_clone));
query_id= memcached_query_id(memc_clone);
test_compare(MEMCACHED_SUCCESS,