+1.0.7
+* Add API call for exist calls.
+
1.0.6 Sat Apr 7 18:26:49 PDT 2012
* Fixes for gcc 4.7, lp:961812
* Fix for restart issue that happens under testing.
AC_CHECK_FUNCS([strtoull])
AC_CHECK_HEADERS([arpa/inet.h])
+AC_CHECK_HEADERS([errno.h])
+AC_CHECK_HEADERS([execinfo.h])
AC_CHECK_HEADERS([fcntl.h])
+AC_CHECK_HEADERS([inttypes.h])
AC_CHECK_HEADERS([libintl.h])
AC_CHECK_HEADERS([limits.h])
AC_CHECK_HEADERS([malloc.h])
+AC_CHECK_HEADERS([math.h])
AC_CHECK_HEADERS([netdb.h])
AC_CHECK_HEADERS([netinet/in.h])
+AC_CHECK_HEADERS([pthread.h])
+AC_CHECK_HEADERS([stdarg.h])
AC_CHECK_HEADERS([stddef.h])
+AC_CHECK_HEADERS([stdlib.h])
AC_CHECK_HEADERS([sys/time.h])
-AC_CHECK_HEADERS([execinfo.h])
+AC_CHECK_HEADERS([unistd.h])
AC_CHECK_HEADERS([cxxabi.h],
AC_DEFINE([HAVE_CXXABI_H], [1], [Have cxxabi.h]),
AC_DEFINE([HAVE_CXXABI_H], [0], [Have cxxabi.h]))
.. c:type:: MEMCACHED_BEHAVIOR_POLL_TIMEOUT
-Modify the timeout value that is used by poll. The default value is -1. An signed int pointer must be passed to memcached_behavior_set to change this value. For memcached_behavior_get a signed int value will be cast and returned as the unsigned long long.
+Modify the timeout value that is used by poll. The default value is -1. An signed int must be passed to memcached_behavior_set to change this value (this requires casting). For memcached_behavior_get a signed int value will be cast and returned as the unsigned long long.
.. c:type:: MEMCACHED_BEHAVIOR_USER_DATA
.. deprecated:: < 0.30
{
if (mem)
{
- free(mem);
+ std::free(mem);
}
}
void *_libmemcached_malloc(const memcached_st *, size_t size, void *)
{
- return malloc(size);
+ return std::malloc(size);
}
void *_libmemcached_realloc(const memcached_st*, void *mem, size_t size, void *)
{
- return realloc(mem, size);
+ return std::realloc(mem, size);
}
void *_libmemcached_calloc(const memcached_st *self, size_t nelem, size_t size, void *context)
return ret;
}
- return calloc(nelem, size);
+ return std::calloc(nelem, size);
}
struct memcached_allocator_t memcached_allocators_return_default(void)
return;
}
- *mem_malloc= self->allocators.malloc;
- *mem_free= self->allocators.free;
- *mem_realloc= self->allocators.realloc;
- *mem_calloc= self->allocators.calloc;
+ if (mem_malloc)
+ {
+ *mem_malloc= self->allocators.malloc;
+ }
+
+ if (mem_free)
+ {
+ *mem_free= self->allocators.free;
+ }
+
+ if (mem_realloc)
+ {
+ *mem_realloc= self->allocators.realloc;
+ }
+
+ if (mem_calloc)
+ {
+ *mem_calloc= self->allocators.calloc;
+ }
}
const uint64_t total_bytes)
{
if (total_items > 0 && total_bytes > 0)
+ {
result->average_item_size= (uint32_t) (total_bytes / total_items);
+ }
}
static void calc_hit_ratio(memcached_analysis_st *result,
{
uint64_t total_items= 0, total_bytes= 0;
uint64_t total_get_cmds= 0, total_get_hits= 0;
- uint32_t server_count;
- if (not memc or not memc_stat)
+ if (memc == NULL or memc_stat == NULL)
{
return NULL;
}
+ memcached_return_t not_used;
+ if (error == NULL)
+ {
+ error= ¬_used;
+ }
+
*error= MEMCACHED_SUCCESS;
- server_count= memcached_server_count(memc);
- memcached_analysis_st *result= (memcached_analysis_st*)calloc(memcached_server_count(memc),
- sizeof(memcached_analysis_st));
+ uint32_t server_count= memcached_server_count(memc);
+ memcached_analysis_st *result= (memcached_analysis_st*)libmemcached_xcalloc(memc,
+ memcached_server_count(memc),
+ memcached_analysis_st);
- if (not result)
+ if (result == NULL)
{
*error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
return NULL;
void memcached_analyze_free(memcached_analysis_st *ptr)
{
- free(ptr);
+ libmemcached_free(ptr->root, ptr);
}
fprintf(stderr, "Number of stack frames obtained: %lu\n", (unsigned long)size);
- char *named_function= (char *)::realloc(NULL, 1024);
+ char *named_function= (char *)std::realloc(NULL, 1024);
if (named_function == NULL)
{
- ::free(strings);
+ std::free(strings);
return;
}
if (USE_DEMANGLE)
{
size_t sz= 200;
- char *named_function_ptr= (char *)::realloc(named_function, sz);
+ char *named_function_ptr= (char *)std::realloc(named_function, sz);
if (named_function_ptr == NULL)
{
continue;
}
}
- ::free(named_function);
- ::free(strings);
+ std::free(named_function);
+ std::free(strings);
#endif // HAVE_EXECINFO_H
}
#include <cstdlib>
#include <cstring>
#include <ctime>
-#include <ctype.h>
+#include <cctype>
+#include <cerrno>
+#include <climits>
#else
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include <errno.h>
+#include <limits.h>
#endif
-#include <errno.h>
#include <fcntl.h>
-#include <limits.h>
#include <sys/types.h>
#include <unistd.h>
{
assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client");
assert_msg(rc != MEMCACHED_SOME_ERRORS, "Programmer error, MEMCACHED_SOME_ERRORS was about to be set on a memcached_server_st");
+
memcached_string_t tmp= { str, length };
return memcached_set_error(self, rc, at, tmp);
}
_error_free(error->next);
- if (error && error->root)
+ if (error and error->root)
{
libmemcached_free(error->root, error);
}
else if (error)
{
- free(error);
+ libmemcached_free(error->root, error);
}
}
return MEMCACHED_INVALID_ARGUMENTS;
}
- if (not memc->error_messages)
+ if (memc->error_messages == NULL)
{
return MEMCACHED_SUCCESS;
}
return 0;
}
- if (not memc->error_messages)
+ if (memc->error_messages == NULL)
{
return 0;
}
return NULL;
}
- if (not server->error_messages)
+ if (server->error_messages == NULL)
{
return memcached_strerror(server->root, MEMCACHED_SUCCESS);
}
- if (not server->error_messages->size)
+ if (server->error_messages->size == 0)
{
return memcached_strerror(server->root, server->error_messages->rc);
}
return true;
}
-static void _free(memcached_st *ptr, bool release_st)
+static void __memcached_free(memcached_st *ptr, bool release_st)
{
/* If we have anything open, lets close it now */
send_quit(ptr);
}
else
{
- ptr= (memcached_st *)malloc(sizeof(memcached_st));
+ ptr= (memcached_st *)libmemcached_xmalloc(NULL, memcached_st);
if (ptr == NULL)
{
bool stored_is_allocated= memcached_is_allocated(ptr);
uint64_t query_id= ptr->query_id;
- _free(ptr, false);
+ __memcached_free(ptr, false);
memcached_create(ptr);
memcached_set_allocated(ptr, stored_is_allocated);
ptr->query_id= query_id;
{
if (ptr)
{
- _free(ptr, true);
+ __memcached_free(ptr, true);
}
}
void *memcached_get_user_data(const memcached_st *ptr)
{
+ if (ptr == NULL)
+ {
+ return NULL;
+ }
+
return ptr->user_data;
}
void *memcached_set_user_data(memcached_st *ptr, void *data)
{
+ if (ptr == NULL)
+ {
+ return NULL;
+ }
+
void *ret= ptr->user_data;
ptr->user_data= data;
memcached_server_write_instance_st memcached_server_instance_fetch(memcached_st *ptr, uint32_t server_key)
{
+ if (ptr == NULL)
+ {
+ return NULL;
+ }
+
return &ptr->servers[server_key];
}
memcached_server_instance_st memcached_server_instance_by_position(const memcached_st *ptr, uint32_t server_key)
{
+ if (ptr == NULL)
+ {
+ return NULL;
+ }
+
return &ptr->servers[server_key];
}
uint64_t memcached_query_id(const memcached_st *self)
{
- if (not self)
+ if (self == NULL)
+ {
return 0;
+ }
return self->query_id;
}
#pragma once
+#include <config.h>
+
#include <libmemcached-1.0/struct/memcached.h>
#ifdef __cplusplus
}
else if (mem)
{
+#ifdef __cplusplus
+ std::free(mem);
+#else
free(mem);
+#endif
}
}
return self->allocators.malloc(self, size, self->allocators.context);
}
+#ifdef __cplusplus
+ return std::malloc(size);
+#else
return malloc(size);
+#endif
}
#define libmemcached_xmalloc(__memcachd_st, __type) ((__type *)libmemcached_malloc((__memcachd_st), sizeof(__type)))
return self->allocators.realloc(self, mem, nmemb * size, self->allocators.context);
}
- return realloc(mem, size);
+#ifdef __cplusplus
+ return std::realloc(mem, size);
+#else
+ return realloc(mem, size);
+#endif
}
#define libmemcached_xrealloc(__memcachd_st, __mem, __nelem, __type) ((__type *)libmemcached_realloc((__memcachd_st), (__mem), (__nelem), sizeof(__type)))
#define libmemcached_xvalloc(__memcachd_st, __nelem, __type) ((__type *)libmemcached_realloc((__memcachd_st), NULL, (__nelem), sizeof(__type)))
return self->allocators.calloc(self, nelem, size, self->allocators.context);
}
- return calloc(nelem, size);
+#ifdef __cplusplus
+ return std::calloc(nelem, size);
+#else
+ return calloc(nelem, size);
+#endif
}
#define libmemcached_xcalloc(__memcachd_st, __nelem, __type) ((__type *)libmemcached_calloc((__memcachd_st), (__nelem), sizeof(__type)))