From: Brian Aker Date: Fri, 5 Feb 2010 01:15:17 +0000 (-0800) Subject: Small cleanup. X-Git-Tag: 0.40~59 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=09ee51ae8bf79232caa43aab2d3450ce2966be7b;p=m6w6%2Flibmemcached Small cleanup. --- diff --git a/libmemcached/constants.h b/libmemcached/constants.h index 561f00c4..f05b03eb 100644 --- a/libmemcached/constants.h +++ b/libmemcached/constants.h @@ -16,7 +16,6 @@ #define MEMCACHED_DEFAULT_PORT 11211 #define MEMCACHED_MAX_KEY 251 /* We add one to have it null terminated */ #define MEMCACHED_MAX_BUFFER 8196 -#define MEMCACHED_MAX_HOST_LENGTH 64 #define MEMCACHED_MAX_HOST_SORT_LENGTH 86 /* Used for Ketama */ #define MEMCACHED_POINTS_PER_SERVER 100 #define MEMCACHED_POINTS_PER_SERVER_KETAMA 160 diff --git a/libmemcached/memcached.h b/libmemcached/memcached.h index 66f8a495..32879c9f 100644 --- a/libmemcached/memcached.h +++ b/libmemcached/memcached.h @@ -13,16 +13,17 @@ #ifndef __LIBMEMCACHED_MEMCACHED_H__ #define __LIBMEMCACHED_MEMCACHED_H__ -#include #include +#include +#include +#include +#include + #if !defined(__cplusplus) # include #endif -#include -#include - #include #include #include diff --git a/libmemcached/server.c b/libmemcached/server.c index 68e1ebaa..6fd685fe 100644 --- a/libmemcached/server.c +++ b/libmemcached/server.c @@ -53,7 +53,7 @@ static inline void _server_init(memcached_server_st *self, const memcached_st *r if (hostname == NULL) self->hostname[0]= 0; else - strncpy(self->hostname, hostname, MEMCACHED_MAX_HOST_LENGTH - 1); + strncpy(self->hostname, hostname, NI_MAXHOST - 1); } static memcached_server_st *_server_create(memcached_server_st *self, const memcached_st *memc) @@ -244,7 +244,7 @@ memcached_return_t memcached_server_remove(memcached_server_st *st_ptr) for (x= 0, host_index= 0; x < memcached_server_count(root); x++) { - if (strncmp(list[x].hostname, st_ptr->hostname, MEMCACHED_MAX_HOST_LENGTH) != 0 || list[x].port != st_ptr->port) + if (strncmp(list[x].hostname, st_ptr->hostname, NI_MAXHOST) != 0 || list[x].port != st_ptr->port) { if (host_index != x) memcpy(list+host_index, list+x, sizeof(memcached_server_st)); diff --git a/libmemcached/server.h b/libmemcached/server.h index 76400ee3..141d71d2 100644 --- a/libmemcached/server.h +++ b/libmemcached/server.h @@ -45,7 +45,7 @@ struct memcached_server_st { uint64_t limit_maxbytes; char read_buffer[MEMCACHED_MAX_BUFFER]; char write_buffer[MEMCACHED_MAX_BUFFER]; - char hostname[MEMCACHED_MAX_HOST_LENGTH]; + char hostname[NI_MAXHOST]; }; diff --git a/tests/hashkit_functions.c b/tests/hashkit_functions.c index 005143a0..2dad25fa 100644 --- a/tests/hashkit_functions.c +++ b/tests/hashkit_functions.c @@ -467,6 +467,7 @@ static test_return_t hashkit_compare_test(hashkit_st *hashk) clone= hashkit_clone(NULL, hashk); test_true(hashkit_compare(clone, hashk)); + hashkit_free(clone); return TEST_SUCCESS; }