perf: avoid writing 1MB of zero bytes

Don't initialize the entire just-allocated buffer to all zeroes.
The very next lines initialize all members except "data".
* exec/totempg.c (assembly_ref): Initialize the first byte of
assembly->data to 0, just in case someone uses it as a string.

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2116 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
Jim Meyering 2009-04-22 07:28:25 +00:00
parent cee464489f
commit 5ac04efe9b

View File

@ -283,12 +283,12 @@ static struct assembly *assembly_ref (unsigned int nodeid)
* Nothing available in inuse or free list, so allocate a new one
*/
assembly = malloc (sizeof (struct assembly));
memset (assembly, 0, sizeof (struct assembly));
/*
* TODO handle memory allocation failure here
*/
assert (assembly);
assembly->nodeid = nodeid;
assembly->data[0] = 0;
assembly->index = 0;
assembly->last_frag_num = 0;
assembly->throw_away_mode = THROW_AWAY_INACTIVE;