commit 386bd9cae471438a685234556111a01a666ca165 from: Neven Sajko via: Dan Cross date: Mon Jan 13 15:08:01 2020 UTC cmd/venti/srv: split memory allocation call This splits a certain vtmallocz call in mkihash into two vtmallocz calls. The first issue this fixes is that the C aliasing rules were not respected in the code before this commit. The other thing is that this enables better memory alignment guarantees. Updates #313 Change-Id: Ia4f3e0fc85facc778193f5e977d4f99a1a9abd23 commit - 0b6b451b71bc116c8b98cdbbfbec3fbca6c8fc17 commit + 386bd9cae471438a685234556111a01a666ca165 blob - 3663345de5da03a3206c7c58a325c98bcab1f57b blob + 700da75488d17066567a4edde4400a9f4d14915a --- src/cmd/venti/srv/icache.c +++ src/cmd/venti/srv/icache.c @@ -68,8 +68,8 @@ mkihash(int size1) size <<= 1; } - ih = vtmallocz(sizeof(IHash)+size*sizeof(ih->table[0])); - ih->table = (IEntry**)(ih+1); + ih = vtmallocz(sizeof(IHash)); + ih->table = vtmallocz(size * sizeof(ih->table[0])); ih->bits = bits; ih->size = size; return ih;