projects
/
m6w6
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Adding test, showing off how to add a custom function to libmemcached.
[m6w6/libmemcached]
/
libmemcached
/
stats.c
diff --git
a/libmemcached/stats.c
b/libmemcached/stats.c
index cf7f4d68355cc87fc668be0a0775c39407e04b0d..128a92f7d1ff7728e64f83487064a5995c6f545e 100644
(file)
--- a/
libmemcached/stats.c
+++ b/
libmemcached/stats.c
@@
-219,7
+219,7
@@
char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *memc_stat,
return NULL;
}
return NULL;
}
- ret=
ptr->call
_malloc(ptr, (size_t) (length + 1));
+ ret=
libmemcached
_malloc(ptr, (size_t) (length + 1));
memcpy(ret, buffer, (size_t) length);
ret[length]= '\0';
memcpy(ret, buffer, (size_t) length);
ret[length]= '\0';
@@
-250,8
+250,8
@@
static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat,
request.message.header.request.bodylen= htonl((uint32_t) len);
if ((memcached_do(instance, request.bytes,
request.message.header.request.bodylen= htonl((uint32_t) len);
if ((memcached_do(instance, request.bytes,
- sizeof(request.bytes),
0
) != MEMCACHED_SUCCESS) ||
- (memcached_io_write(instance, args, len,
1
) == -1))
+ sizeof(request.bytes),
false
) != MEMCACHED_SUCCESS) ||
+ (memcached_io_write(instance, args, len,
true
) == -1))
{
memcached_io_reset(instance);
return MEMCACHED_WRITE_FAILURE;
{
memcached_io_reset(instance);
return MEMCACHED_WRITE_FAILURE;
@@
-260,7
+260,7
@@
static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat,
else
{
if (memcached_do(instance, request.bytes,
else
{
if (memcached_do(instance, request.bytes,
- sizeof(request.bytes),
1
) != MEMCACHED_SUCCESS)
+ sizeof(request.bytes),
true
) != MEMCACHED_SUCCESS)
{
memcached_io_reset(instance);
return MEMCACHED_WRITE_FAILURE;
{
memcached_io_reset(instance);
return MEMCACHED_WRITE_FAILURE;
@@
-314,7
+314,7
@@
static memcached_return_t ascii_stats_fetch(memcached_stat_st *memc_stat,
if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
return MEMCACHED_WRITE_FAILURE;
if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
return MEMCACHED_WRITE_FAILURE;
- rc= memcached_do(instance, buffer, send_length,
1
);
+ rc= memcached_do(instance, buffer, send_length,
true
);
if (rc != MEMCACHED_SUCCESS)
goto error;
if (rc != MEMCACHED_SUCCESS)
goto error;
@@
-357,7
+357,6
@@
error:
memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return_t *error)
{
memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return_t *error)
{
- uint32_t x;
memcached_return_t rc;
memcached_stat_st *stats;
memcached_return_t rc;
memcached_stat_st *stats;
@@
-367,31
+366,34
@@
memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_retur
return NULL;
}
return NULL;
}
- stats=
ptr->call
_calloc(ptr, memcached_server_count(ptr), sizeof(memcached_stat_st));
+ stats=
libmemcached
_calloc(ptr, memcached_server_count(ptr), sizeof(memcached_stat_st));
- stats->root= ptr;
-
- if (!stats)
+ if (! stats)
{
*error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
return NULL;
}
rc= MEMCACHED_SUCCESS;
{
*error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
return NULL;
}
rc= MEMCACHED_SUCCESS;
- for (x= 0; x < memcached_server_count(ptr); x++)
+ for (
uint32_t
x= 0; x < memcached_server_count(ptr); x++)
{
memcached_return_t temp_return;
memcached_server_instance_st *instance;
{
memcached_return_t temp_return;
memcached_server_instance_st *instance;
+ memcached_stat_st *stat_instance;
+
+ stat_instance= stats + x;
+
+ stat_instance->root= ptr;
instance= memcached_server_instance_fetch(ptr, x);
if (ptr->flags.binary_protocol)
{
instance= memcached_server_instance_fetch(ptr, x);
if (ptr->flags.binary_protocol)
{
- temp_return= binary_stats_fetch(stat
s + x
, args, instance);
+ temp_return= binary_stats_fetch(stat
_instance
, args, instance);
}
else
{
}
else
{
- temp_return= ascii_stats_fetch(stat
s + x
, args, instance);
+ temp_return= ascii_stats_fetch(stat
_instance
, args, instance);
}
if (temp_return != MEMCACHED_SUCCESS)
}
if (temp_return != MEMCACHED_SUCCESS)
@@
-435,16
+437,18
@@
memcached_return_t memcached_stat_servername(memcached_stat_st *memc_stat, char
We make a copy of the keys since at some point in the not so distant future
we will add support for "found" keys.
*/
We make a copy of the keys since at some point in the not so distant future
we will add support for "found" keys.
*/
-char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *memc_stat,
+char ** memcached_stat_get_keys(memcached_st *ptr,
+ memcached_stat_st *memc_stat,
memcached_return_t *error)
{
memcached_return_t *error)
{
- (void) memc_stat;
char **list;
size_t length= sizeof(memcached_stat_keys);
char **list;
size_t length= sizeof(memcached_stat_keys);
- list= ptr->call_malloc(ptr, length);
+ (void)memc_stat;
+
+ list= libmemcached_malloc(ptr, length);
- if (!list)
+ if (!
list)
{
*error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
return NULL;
{
*error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
return NULL;
@@
-467,11
+471,11
@@
void memcached_stat_free(memcached_st *ptr, memcached_stat_st *memc_stat)
if (memc_stat->root)
{
if (memc_stat->root)
{
-
memc_stat->root->call_free(ptr
, memc_stat);
+
libmemcached_free(memc_stat->root
, memc_stat);
}
else if (ptr)
{
}
else if (ptr)
{
-
ptr->call
_free(ptr, memc_stat);
+
libmemcached
_free(ptr, memc_stat);
}
else
{
}
else
{