projects
/
awesomized
/
libmemcached
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
|
github
raw
|
patch
|
inline
| side by side (parent:
7b8b670
)
Flip call (NULL is more common). Also add in helgrind and fix calloc.
author
<brian@localhost.localdomain>
<>
Thu, 14 May 2009 04:11:04 +0000
(21:11 -0700)
committer
<brian@localhost.localdomain>
<>
Thu, 14 May 2009 04:11:04 +0000
(21:11 -0700)
12 files changed:
ChangeLog
patch
|
blob
|
history
clients/memslap.c
patch
|
blob
|
history
docs/memcached_callback.pod
patch
|
blob
|
history
libmemcached/memcached.c
patch
|
blob
|
history
libmemcached/memcached_analyze.c
patch
|
blob
|
history
libmemcached/memcached_fetch.c
patch
|
blob
|
history
libmemcached/memcached_result.c
patch
|
blob
|
history
libmemcached/memcached_server.c
patch
|
blob
|
history
libmemcached/memcached_stats.c
patch
|
blob
|
history
libmemcached/memcached_string.c
patch
|
blob
|
history
tests/Makefile.am
patch
|
blob
|
history
tests/function.c
patch
|
blob
|
history
diff --git
a/ChangeLog
b/ChangeLog
index 63bec5187568626442bb271942e97cfc2d4a0f07..d5b9b0292d4ac5ad0d4b4fe4c52357a5e569dece 100644
(file)
--- a/
ChangeLog
+++ b/
ChangeLog
@@
-1,4
+1,5
@@
-0.29 Wed May 13 08:06:05 PDT 2009
+0.29
+ * Fixed malloc usage to calloc for spots where we need zero filled memory.
* All code warnings now treated as errors.
* Fixes for debian packaging.
* Added new pooling mechanism.
* All code warnings now treated as errors.
* Fixes for debian packaging.
* Added new pooling mechanism.
diff --git
a/clients/memslap.c
b/clients/memslap.c
index d85642f8d32a6ebc4a27df491087c7b6af454b70..509204eb6a4ee735dcd149cac466246769d2e7f4 100644
(file)
--- a/
clients/memslap.c
+++ b/
clients/memslap.c
@@
-178,8
+178,7
@@
void scheduler(memcached_server_st *servers, conclusions_st *conclusion)
for (x= 0; x < opt_concurrency; x++)
{
thread_context_st *context;
for (x= 0; x < opt_concurrency; x++)
{
thread_context_st *context;
- context= (thread_context_st *)malloc(sizeof(thread_context_st));
- memset(context, 0, sizeof(thread_context_st));
+ context= (thread_context_st *)calloc(1, sizeof(thread_context_st));
context->memc= memcached_clone(NULL, memc);
context->test= opt_test;
context->memc= memcached_clone(NULL, memc);
context->test= opt_test;
diff --git
a/docs/memcached_callback.pod
b/docs/memcached_callback.pod
index 5aa2e3b491812f77c3ce8f925f25ef1487b241d9..a11f9585deac8a108c2f8f075e32d11a610b0c3e 100644
(file)
--- a/
docs/memcached_callback.pod
+++ b/
docs/memcached_callback.pod
@@
-65,6
+65,7
@@
will copy the pointer to the clone.
=item MEMCACHED_CALLBACK_MALLOC_FUNCTION
This alllows yout to pass in a customized version of malloc that will be used instead of the builtin malloc(3) call.
=item MEMCACHED_CALLBACK_MALLOC_FUNCTION
This alllows yout to pass in a customized version of malloc that will be used instead of the builtin malloc(3) call.
+Your malloc must zero all memory.
The prototype for this is:
void *(*memcached_malloc_function)(memcached_st *ptr, const size_t size);
The prototype for this is:
void *(*memcached_malloc_function)(memcached_st *ptr, const size_t size);
diff --git
a/libmemcached/memcached.c
b/libmemcached/memcached.c
index 52b3834b7752fcfee7bb720e02c895c09c837fa6..a93bef7d651512ac7d49c4cf92e260fb200fb866 100644
(file)
--- a/
libmemcached/memcached.c
+++ b/
libmemcached/memcached.c
@@
-9,12
+9,11
@@
memcached_st *memcached_create(memcached_st *ptr)
if (ptr == NULL)
{
if (ptr == NULL)
{
- ptr= (memcached_st *)
malloc(
sizeof(memcached_st));
+ ptr= (memcached_st *)
calloc(1,
sizeof(memcached_st));
if (!ptr)
return NULL; /* MEMCACHED_MEMORY_ALLOCATION_FAILURE */
if (!ptr)
return NULL; /* MEMCACHED_MEMORY_ALLOCATION_FAILURE */
- memset(ptr, 0, sizeof(memcached_st));
ptr->is_allocated= true;
}
else
ptr->is_allocated= true;
}
else
diff --git
a/libmemcached/memcached_analyze.c
b/libmemcached/memcached_analyze.c
index 1063fb277237b143e7ba162d0ba3e5b98e118aef..583d828f012986cbdea937a6da75f34377c077b3 100644
(file)
--- a/
libmemcached/memcached_analyze.c
+++ b/
libmemcached/memcached_analyze.c
@@
-70,7
+70,7
@@
memcached_analysis_st *memcached_analyze(memcached_st *memc,
*error= MEMCACHED_SUCCESS;
server_count= memcached_server_count(memc);
*error= MEMCACHED_SUCCESS;
server_count= memcached_server_count(memc);
- result= (memcached_analysis_st*)
malloc(
sizeof(memcached_analysis_st)
+ result= (memcached_analysis_st*)
calloc(1,
sizeof(memcached_analysis_st)
* (memc->number_of_hosts));
if (!result)
{
* (memc->number_of_hosts));
if (!result)
{
@@
-78,8
+78,6
@@
memcached_analysis_st *memcached_analyze(memcached_st *memc,
return NULL;
}
return NULL;
}
- memset(result, 0, sizeof(*result));
-
for (x= 0; x < server_count; x++)
{
calc_largest_consumption(result, x, stat[x].bytes);
for (x= 0; x < server_count; x++)
{
calc_largest_consumption(result, x, stat[x].bytes);
diff --git
a/libmemcached/memcached_fetch.c
b/libmemcached/memcached_fetch.c
index e9939890472c3ee8e12663d94ee021685b608978..8afdfd045693a82111bde92947dffe93c448b027 100644
(file)
--- a/
libmemcached/memcached_fetch.c
+++ b/
libmemcached/memcached_fetch.c
@@
-16,8
+16,9
@@
char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length,
result_buffer= memcached_fetch_result(ptr, result_buffer, error);
result_buffer= memcached_fetch_result(ptr, result_buffer, error);
- if (
*error != MEMCACHED_SUCCESS || result_buffer == NULL
)
+ if (
result_buffer == NULL || *error != MEMCACHED_SUCCESS
)
{
{
+ WATCHPOINT_ASSERT(result_buffer == NULL);
*value_length= 0;
return NULL;
}
*value_length= 0;
return NULL;
}
@@
-54,7
+55,8
@@
memcached_result_st *memcached_fetch_result(memcached_st *ptr,
if ((result= memcached_result_create(ptr, NULL)) == NULL)
return NULL;
if ((result= memcached_result_create(ptr, NULL)) == NULL)
return NULL;
- while ((server = memcached_io_get_readable_server(ptr)) != NULL) {
+ while ((server = memcached_io_get_readable_server(ptr)) != NULL)
+ {
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
*error= memcached_response(server, buffer, sizeof(buffer), result);
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
*error= memcached_response(server, buffer, sizeof(buffer), result);
diff --git
a/libmemcached/memcached_result.c
b/libmemcached/memcached_result.c
index 8d376f680fd45ced6ef1cd6a88b4f3f21ed19666..fac3b8c554d7c794676059ae594d7b8e48747ec5 100644
(file)
--- a/
libmemcached/memcached_result.c
+++ b/
libmemcached/memcached_result.c
@@
-17,11
+17,10
@@
memcached_result_st *memcached_result_create(memcached_st *memc,
if (memc->call_malloc)
ptr= (memcached_result_st *)memc->call_malloc(memc, sizeof(memcached_result_st));
else
if (memc->call_malloc)
ptr= (memcached_result_st *)memc->call_malloc(memc, sizeof(memcached_result_st));
else
- ptr= (memcached_result_st *)
malloc(
sizeof(memcached_result_st));
+ ptr= (memcached_result_st *)
calloc(1,
sizeof(memcached_result_st));
if (ptr == NULL)
return NULL;
if (ptr == NULL)
return NULL;
- memset(ptr, 0, sizeof(memcached_result_st));
ptr->is_allocated= true;
}
ptr->is_allocated= true;
}
diff --git
a/libmemcached/memcached_server.c
b/libmemcached/memcached_server.c
index 4aebfd3b7367506dfb030cb64794226fd56d2b29..7fff6cdb4fdb96aa146bb8e7f6d32a6f9c9b2882 100644
(file)
--- a/
libmemcached/memcached_server.c
+++ b/
libmemcached/memcached_server.c
@@
-7,12
+7,11
@@
memcached_server_st *memcached_server_create(memcached_st *memc, memcached_serve
{
if (ptr == NULL)
{
{
if (ptr == NULL)
{
- ptr= (memcached_server_st *)
malloc(
sizeof(memcached_server_st));
+ ptr= (memcached_server_st *)
calloc(1,
sizeof(memcached_server_st));
if (!ptr)
return NULL; /* MEMCACHED_MEMORY_ALLOCATION_FAILURE */
if (!ptr)
return NULL; /* MEMCACHED_MEMORY_ALLOCATION_FAILURE */
- memset(ptr, 0, sizeof(memcached_server_st));
ptr->is_allocated= true;
}
else
ptr->is_allocated= true;
}
else
diff --git
a/libmemcached/memcached_stats.c
b/libmemcached/memcached_stats.c
index d5ec819ff6853504173f31e95cfed272bae23854..e6a4e07f161f6f95df241d7ceb61b11ac5458802 100644
(file)
--- a/
libmemcached/memcached_stats.c
+++ b/
libmemcached/memcached_stats.c
@@
-360,14
+360,13
@@
memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_retur
if (ptr->call_malloc)
stats= (memcached_stat_st *)ptr->call_malloc(ptr, sizeof(memcached_stat_st)*(ptr->number_of_hosts));
else
if (ptr->call_malloc)
stats= (memcached_stat_st *)ptr->call_malloc(ptr, sizeof(memcached_stat_st)*(ptr->number_of_hosts));
else
- stats= (memcached_stat_st *)
malloc(
sizeof(memcached_stat_st)*(ptr->number_of_hosts));
+ stats= (memcached_stat_st *)
calloc(1,
sizeof(memcached_stat_st)*(ptr->number_of_hosts));
if (!stats)
{
*error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
return NULL;
}
if (!stats)
{
*error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
return NULL;
}
- memset(stats, 0, sizeof(memcached_stat_st)*(ptr->number_of_hosts));
rc= MEMCACHED_SUCCESS;
for (x= 0; x < ptr->number_of_hosts; x++)
rc= MEMCACHED_SUCCESS;
for (x= 0; x < ptr->number_of_hosts; x++)
@@
-420,14
+419,13
@@
char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *stat __att
if (ptr->call_malloc)
list= (char **)ptr->call_malloc(ptr, length);
else
if (ptr->call_malloc)
list= (char **)ptr->call_malloc(ptr, length);
else
- list= (char **)
malloc(
length);
+ list= (char **)
calloc(1,
length);
if (!list)
{
*error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
return NULL;
}
if (!list)
{
*error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
return NULL;
}
- memset(list, 0, sizeof(memcached_stat_keys));
memcpy(list, memcached_stat_keys, sizeof(memcached_stat_keys));
memcpy(list, memcached_stat_keys, sizeof(memcached_stat_keys));
diff --git
a/libmemcached/memcached_string.c
b/libmemcached/memcached_string.c
index 5a6f190e5dd9f1fdbd526df01afffc991b1ce280..3bac225afe2e5e80ae0aee780bb25aa1edd6e845 100644
(file)
--- a/
libmemcached/memcached_string.c
+++ b/
libmemcached/memcached_string.c
@@
-47,11
+47,10
@@
memcached_string_st *memcached_string_create(memcached_st *ptr, memcached_string
if (ptr->call_malloc)
string= (memcached_string_st *)ptr->call_malloc(ptr, sizeof(memcached_string_st));
else
if (ptr->call_malloc)
string= (memcached_string_st *)ptr->call_malloc(ptr, sizeof(memcached_string_st));
else
- string= (memcached_string_st *)
malloc(
sizeof(memcached_string_st));
+ string= (memcached_string_st *)
calloc(1,
sizeof(memcached_string_st));
if (string == NULL)
return NULL;
if (string == NULL)
return NULL;
- memset(string, 0, sizeof(memcached_string_st));
string->is_allocated= true;
}
string->block_size= MEMCACHED_BLOCK_SIZE;
string->is_allocated= true;
}
string->block_size= MEMCACHED_BLOCK_SIZE;
diff --git
a/tests/Makefile.am
b/tests/Makefile.am
index dc242acafabc3b788f3d5f06a7d069d64f75ce7f..dd7ba749c9bb3b450ae0fe9d7a4612a5bce15ab5 100644
(file)
--- a/
tests/Makefile.am
+++ b/
tests/Makefile.am
@@
-85,6
+85,13
@@
callgrind:
libtool --mode=execute valgrind --tool=callgrind testapp
callgrind_annotate callgrind.out.* --auto=yes > /tmp/callgrind.out
libtool --mode=execute valgrind --tool=callgrind testapp
callgrind_annotate callgrind.out.* --auto=yes > /tmp/callgrind.out
+helgrind:
+ rm -f helgrind.out.*
+ libtool --mode=execute valgrind --tool=helgrind testapp
+
+helgrind-slap:
+ libtool --mode=execute valgrind --tool=helgrind ../clients/memslap --server=localhost --concurrency=30
+
test-no-outputdiff: testapp
./testapp > /dev/null
@echo "Test completed"
test-no-outputdiff: testapp
./testapp > /dev/null
@echo "Test completed"
diff --git
a/tests/function.c
b/tests/function.c
index cd7a82cafe10b1eb22dcce1083e14eda195ee486..86a255ba326a3bd956fa6b839e7dd27399b45bcb 100644
(file)
--- a/
tests/function.c
+++ b/
tests/function.c
@@
-3035,7
+3035,7
@@
static void my_free(memcached_st *ptr __attribute__((unused)), void *mem)
static void *my_malloc(memcached_st *ptr __attribute__((unused)), const size_t size)
{
static void *my_malloc(memcached_st *ptr __attribute__((unused)), const size_t size)
{
- return
malloc(
size);
+ return
calloc(1,
size);
}
static void *my_realloc(memcached_st *ptr __attribute__((unused)), void *mem, const size_t size)
}
static void *my_realloc(memcached_st *ptr __attribute__((unused)), void *mem, const size_t size)