*
*/
-#include <config.h>
-#include <libmemcached/memcached.h>
-#include <libmemcached/virtual_bucket.h>
+#include <libmemcached/common.h>
struct bucket_t {
uint32_t master;
const uint32_t replicas)
{
if (! self || ! host_map || ! buckets)
+ {
return MEMCACHED_INVALID_ARGUMENTS;
+ }
memcached_virtual_bucket_free(self);
struct memcached_virtual_bucket_t *virtual_bucket= (struct memcached_virtual_bucket_t *)malloc(sizeof(struct memcached_virtual_bucket_t) + sizeof(struct bucket_t) *buckets);
- if (! virtual_bucket)
+ if (virtual_bucket == NULL)
+ {
return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+ }
+
virtual_bucket->size= buckets;
virtual_bucket->replicas= replicas;
self->virtual_bucket= virtual_bucket;
- for (uint32_t x=0; x < buckets; x++)
+ uint32_t x= 0;
+ for (; x < buckets; x++)
{
virtual_bucket->buckets[x].master= host_map[x];
if (forward_map)
virtual_bucket->buckets[x].forward= 0;
}
}
-
return MEMCACHED_SUCCESS;
}
void memcached_virtual_bucket_free(memcached_st *self)
{
- if (! self)
+ if (self == NULL)
+ {
return;
+ }
- if (! self->virtual_bucket)
+ if (self->virtual_bucket == NULL)
+ {
return;
+ }
free(self->virtual_bucket);
self->virtual_bucket= NULL;
uint32_t memcached_virtual_bucket_get(const memcached_st *self, uint32_t digest)
{
- if (! self)
+ if (self == NULL)
+ {
return 0;
+ }
- if (! self->virtual_bucket)
+ if (self->virtual_bucket == NULL)
+ {
return 0;
+ }
if (self->virtual_bucket)
{