From: Brian Aker Date: Wed, 28 Nov 2007 01:20:20 +0000 (-0800) Subject: Fix for source specfile (aka source RPM). X-Git-Tag: 0.13~67 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=128e13163e0f26383f888fe0bb284d569562ca6c;p=awesomized%2Flibmemcached Fix for source specfile (aka source RPM). Modified hostname to be static allocation (saves the system call at the cost of 64 bytes of memory in servers_st structure). --- diff --git a/docs/memcached_servers.pod b/docs/memcached_servers.pod index fa0881ac..2fbd1a66 100755 --- a/docs/memcached_servers.pod +++ b/docs/memcached_servers.pod @@ -49,7 +49,8 @@ allowed, so duplication is not checked. memcached_server_add_unix_socket() pushes a single UNIX socket into the C structure. This UNIX socket will be placed at the end. -Duplicate servers are allowed, so duplication is not checked. +Duplicate servers are allowed, so duplication is not checked. The length +of the filename must be one character less then MEMCACHED_MAX_HOST_LENGTH. memcached_server_push() pushes an array of C into the C structure. These servers will be placed at the diff --git a/include/memcached.h b/include/memcached.h index 4e60cca0..3d1bfcd8 100644 --- a/include/memcached.h +++ b/include/memcached.h @@ -32,6 +32,7 @@ typedef struct memcached_server_st memcached_server_st; #define HUGE_STRING_LEN 8196 #define MEMCACHED_MAX_KEY 251 /* We add one to have it null terminated */ #define MEMCACHED_MAX_BUFFER HUGE_STRING_LEN +#define MEMCACHED_MAX_HOST_LENGTH 64 typedef enum { MEMCACHED_SUCCESS, @@ -104,7 +105,7 @@ typedef enum { } memcached_allocated; struct memcached_server_st { - char *hostname; + char hostname[MEMCACHED_MAX_HOST_LENGTH]; unsigned int port; int fd; unsigned int stack_responses; diff --git a/lib/memcached_hosts.c b/lib/memcached_hosts.c index fac03707..4b871d6b 100644 --- a/lib/memcached_hosts.c +++ b/lib/memcached_hosts.c @@ -10,7 +10,7 @@ static void host_reset(memcached_server_st *host, char *hostname, unsigned int p memcached_connection type) { memset(host, 0, sizeof(memcached_server_st)); - host->hostname= strdup(hostname); + memcpy(host->hostname, hostname, strlen(hostname)); host->port= port; host->fd= -1; host->type= type; @@ -41,7 +41,7 @@ memcached_return memcached_server_push(memcached_st *ptr, memcached_server_st *l for (x= 0; x < count; x++) { - WATCHPOINT_ASSERT(list[x].hostname); + WATCHPOINT_ASSERT(list[x].hostname[0] == 0); host_reset(&ptr->hosts[ptr->number_of_hosts], list[x].hostname, list[x].port, list[x].type); ptr->number_of_hosts++; @@ -160,8 +160,5 @@ void memcached_server_list_free(memcached_server_st *ptr) if (ptr == NULL) return; - for (x= 0; x < ptr[0].count; x++) - free(ptr[x].hostname); - free(ptr); } diff --git a/support/libmemcached.spec.in b/support/libmemcached.spec.in index 86220b54..2ed34137 100644 --- a/support/libmemcached.spec.in +++ b/support/libmemcached.spec.in @@ -4,6 +4,7 @@ Version: @VERSION@ Release: 1 License: BSD Group: System Environment/Libraries +BuildRequires: gcc-c++ URL: http://tangent.org/552/libmemcached.html Packager: Jeff Fisher