From 5ac04efe9bbe6624e7f771a83d431179fc5b589d Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 22 Apr 2009 07:28:25 +0000 Subject: [PATCH] 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 --- exec/totempg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exec/totempg.c b/exec/totempg.c index 2d97e686..47f84136 100644 --- a/exec/totempg.c +++ b/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 */ 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;