Browse Source

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
Jim Meyering 17 years ago
parent
commit
5ac04efe9b
1 changed files with 1 additions and 1 deletions
  1. 1 1
      exec/totempg.c

+ 1 - 1
exec/totempg.c

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