X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=libhashkit%2Fhashkit.cc;h=e397871f491eea54fe99c592bf81f1e1a162e5f3;hb=983523c4536f12781533124cb8a00a4291b8cf79;hp=96e39515efe9dde16cdbce1bdf43a39209ceb1e0;hpb=3dcd41c50068eec906a1a11a178e9b3f08ef2326;p=m6w6%2Flibmemcached diff --git a/libhashkit/hashkit.cc b/libhashkit/hashkit.cc index 96e39515..e397871f 100644 --- a/libhashkit/hashkit.cc +++ b/libhashkit/hashkit.cc @@ -17,24 +17,25 @@ static inline void _hashkit_init(hashkit_st *self) self->distribution_hash.context= NULL; self->flags.is_base_same_distributed= true; + self->_key= NULL; } static inline hashkit_st *_hashkit_create(hashkit_st *self) { - if (not self) + if (self) + { + self->options.is_allocated= false; + } + else { self= (hashkit_st*)calloc(1, sizeof(hashkit_st)); - if (not self) + if (self == NULL) { return NULL; } self->options.is_allocated= true; } - else - { - self->options.is_allocated= false; - } return self; } @@ -42,8 +43,10 @@ static inline hashkit_st *_hashkit_create(hashkit_st *self) hashkit_st *hashkit_create(hashkit_st *self) { self= _hashkit_create(self); - if (not self) - return self; + if (self == NULL) + { + return NULL; + } _hashkit_init(self); @@ -53,6 +56,12 @@ hashkit_st *hashkit_create(hashkit_st *self) void hashkit_free(hashkit_st *self) { + if (self and self->_key) + { + free(self->_key); + self->_key= NULL; + } + if (hashkit_is_allocated(self)) { free(self); @@ -78,6 +87,7 @@ hashkit_st *hashkit_clone(hashkit_st *destination, const hashkit_st *source) destination->base_hash= source->base_hash; destination->distribution_hash= source->distribution_hash; destination->flags= source->flags; + destination->_key= aes_clone_key(static_cast(source->_key)); return destination; }