{
if (not self)
{
- self= new hashkit_st;
+ self= (hashkit_st*)calloc(1, sizeof(hashkit_st));
if (not self)
{
return NULL;
{
if (hashkit_is_allocated(self))
{
- delete self;
+ free(self);
}
}
#include <cstdio>
#ifdef NDEBUG
-#define assert(__expr, __mesg) ((void)0)
+#define assert_msg(__expr, __mesg) (void)(__expr); (void)(__mesg);
#else
#define assert_msg(__expr, __mesg) \
case MEMCACHED_BEHAVIOR_MAX:
default:
- /* Shouldn't get here */
- assert_msg(0, "Invalid behavior passed to memcached_behavior_set()");
- return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
- memcached_literal_param("Invalid behavior passed to memcached_behavior_set()"));
+ /* Shouldn't get here */
+ assert_msg(0, "Invalid behavior passed to memcached_behavior_set()");
+ return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
+ memcached_literal_param("Invalid behavior passed to memcached_behavior_set()"));
}
return MEMCACHED_SUCCESS;
if (is_ketama_weighted)
{
float pct= (float)list[host_index].weight / (float)total_weight;
- pointer_per_server= (uint32_t) ((floorf((float) (pct * MEMCACHED_POINTS_PER_SERVER_KETAMA / 4 * (float)live_servers + 0.0000000001))) * 4);
+ pointer_per_server= (uint32_t) ((floor((float) (pct * MEMCACHED_POINTS_PER_SERVER_KETAMA / 4 * (float)live_servers + 0.0000000001))) * 4);
pointer_per_hash= 4;
if (DEBUG)
{
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached library
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-#ifndef CACHE_H
-#define CACHE_H
+#pragma once
+
#include <pthread.h>
#ifdef HAVE_UMEM_H
-#include <umem.h>
-#define cache_t umem_cache_t
-#define cache_alloc(a) umem_cache_alloc(a, UMEM_DEFAULT)
-#define cache_free(a, b) umem_cache_free(a, b)
-#define cache_create(a,b,c,d,e) umem_cache_create((char*)a, b, c, d, e, NULL, NULL, NULL, 0)
-#define cache_destroy(a) umem_cache_destroy(a);
-
+# include <umem.h>
+# define cache_t umem_cache_t
+# define cache_alloc(a) umem_cache_alloc(a, UMEM_DEFAULT)
+# define cache_free(a, b) umem_cache_free(a, b)
+# define cache_create(a,b,c,d,e) umem_cache_create((char*)a, b, c, d, e, NULL, NULL, NULL, 0)
+# define cache_destroy(a) umem_cache_destroy(a);
#else
-
-#ifndef NDEBUG
+# ifndef NDEBUG
/* may be used for debug purposes */
extern int cache_error;
-#endif
+# endif
/**
* Constructor used to initialize allocated objects
* @param ptr pointer to the object to return.
*/
void cache_free(cache_t* handle, void* ptr);
-#endif
-
-#endif
+#endif // HAVE_UMEM_H
+++ /dev/null
-dnl Copyright (C) 2010 Monty Taylor
-dnl This file is free software; Monty Taylor
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([_PANDORA_SEARCH_LIBGTEST],[
- AC_REQUIRE([AC_LIB_PREFIX])
-
- dnl --------------------------------------------------------------------
- dnl Check for libgtest
- dnl --------------------------------------------------------------------
-
- AC_ARG_ENABLE([libgtest],
- [AS_HELP_STRING([--disable-libgtest],
- [Build with libgtest support @<:@default=on@:>@])],
- [ac_enable_libgtest="$enableval"],
- [ac_enable_libgtest="yes"])
-
- AS_IF([test "x$ac_enable_libgtest" = "xyes"],[
- AC_LANG_PUSH(C++)
- save_CXXFLAGS="${CXXFLAGS}"
- CXXFLAGS="${AM_CXXFLAGS} ${CXXFLAGS}"
- AC_LIB_HAVE_LINKFLAGS(gtest,,[
- #include <gtest/gtest.h>
-TEST(pandora_test_libgtest, PandoraTest)
-{
- ASSERT_EQ(1, 1);
-}
- ],[])
- CXXFLAGS="${save_CXXFLAGS}"
- AC_LANG_POP()
- ],[
- ac_cv_libgtest="no"
- ])
-
- AM_CONDITIONAL(HAVE_LIBGTEST, [test "x${ac_cv_libgtest}" = "xyes"])
-])
-
-AC_DEFUN([PANDORA_HAVE_LIBGTEST],[
- AC_REQUIRE([_PANDORA_SEARCH_LIBGTEST])
-])
-
-AC_DEFUN([PANDORA_REQUIRE_LIBGTEST],[
- AC_REQUIRE([_PANDORA_SEARCH_LIBGTEST])
- AS_IF([test "x${ac_cv_libgtest}" = "xno"],
- AC_MSG_ERROR([libgtest is required for ${PACKAGE}]))
-])
uint32_t hash_val;
hash_val= libhashkit_crc32(*ptr, strlen(*ptr));
- assert(crc_values[x] == hash_val);
+ test_compare(crc_values[x], hash_val);
}
return TEST_SUCCESS;
uint32_t hash_val;
hash_val= libhashkit_fnv1_64(*ptr, strlen(*ptr));
- assert(fnv1_64_values[x] == hash_val);
+ test_compare(fnv1_64_values[x], hash_val);
}
return TEST_SUCCESS;
uint32_t hash_val;
hash_val= libhashkit_fnv1a_64(*ptr, strlen(*ptr));
- assert(fnv1a_64_values[x] == hash_val);
+ test_compare(fnv1a_64_values[x], hash_val);
}
return TEST_SUCCESS;
uint32_t hash_val;
hash_val= libhashkit_fnv1_32(*ptr, strlen(*ptr));
- assert(fnv1_32_values[x] == hash_val);
+ test_compare(fnv1_32_values[x], hash_val);
}
return TEST_SUCCESS;
uint32_t hash_val;
hash_val= libhashkit_fnv1a_32(*ptr, strlen(*ptr));
- assert(fnv1a_32_values[x] == hash_val);
+ test_compare(fnv1a_32_values[x], hash_val);
}
return TEST_SUCCESS;
#else
hash_val= 1;
#endif
- assert(hsieh_values[x] == hash_val);
+ test_compare(hsieh_values[x], hash_val);
}
return TEST_SUCCESS;
#else
hash_val= 1;
#endif
- assert(murmur_values[x] == hash_val);
+ test_compare(murmur_values[x], hash_val);
}
return TEST_SUCCESS;
uint32_t hash_val;
hash_val= libhashkit_jenkins(*ptr, strlen(*ptr));
- assert(jenkins_values[x] == hash_val);
+ test_compare(jenkins_values[x], hash_val);
}
return TEST_SUCCESS;