+2005-10-22 Simon Josefsson <jas@extundo.com>
+
+ * md4.c, md4.c: Simplify buffer handling visavi alignment,
+ suggested by Bruno Haible <bruno@clisp.org>.
+
2005-10-22 Simon Josefsson <jas@extundo.com>
* crc.h: Include stddef.h, for size_t.
++ctx->total[1];
pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes;
- memcpy (&ctx->buffer[bytes], fillbuf, pad);
+ memcpy (&((char*)ctx->buffer)[bytes], fillbuf, pad);
/* Put the 64-bit file length in *bits* at the end of the buffer. */
- *(uint32_t *) &ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3);
- *(uint32_t *) &ctx->buffer[bytes + pad + 4] = SWAP ((ctx->total[1] << 3) |
- (ctx->total[0] >> 29));
+ ctx->buffer[(bytes + pad) / 4] = SWAP (ctx->total[0] << 3);
+ ctx->buffer[(bytes + pad) / 4 + 1] = SWAP ((ctx->total[1] << 3) |
+ (ctx->total[0] >> 29));
/* Process last bytes. */
md4_process_block (ctx->buffer, bytes + pad + 8, ctx);
size_t left_over = ctx->buflen;
size_t add = 128 - left_over > len ? len : 128 - left_over;
- memcpy (&ctx->buffer[left_over], buffer, add);
+ memcpy (&((char*)ctx->buffer)[left_over], buffer, add);
ctx->buflen += add;
if (ctx->buflen > 64)
ctx->buflen &= 63;
/* The regions in the following copy operation cannot overlap. */
- memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
+ memcpy (ctx->buffer, &((char*)ctx->buffer)[(left_over + add) & ~63],
ctx->buflen);
}
{
size_t left_over = ctx->buflen;
- memcpy (&ctx->buffer[left_over], buffer, len);
+ memcpy (&((char*)ctx->buffer)[left_over], buffer, len);
left_over += len;
if (left_over >= 64)
{
md4_process_block (ctx->buffer, 64, ctx);
left_over -= 64;
- memcpy (ctx->buffer, &ctx->buffer[64], left_over);
+ memcpy (ctx->buffer, &ctx->buffer[16], left_over);
}
ctx->buflen = left_over;
}