Mercurial > hg > octave-lyh > gnulib-hg
changeset 6422:833177ba48f0
* md4.c, md4.c: Simplify buffer handling visavi alignment,
suggested by Bruno Haible <bruno@clisp.org>.
author | Simon Josefsson <simon@josefsson.org> |
---|---|
date | Sat, 22 Oct 2005 16:32:14 +0000 |
parents | 36fc37878824 |
children | 4e611c25a13f |
files | lib/ChangeLog lib/md4.c lib/md4.h |
diffstat | 3 files changed, 15 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +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.
--- a/lib/md4.c +++ b/lib/md4.c @@ -100,12 +100,12 @@ ++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); @@ -208,7 +208,7 @@ 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) @@ -217,7 +217,7 @@ 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); } @@ -258,13 +258,13 @@ { 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; }
--- a/lib/md4.h +++ b/lib/md4.h @@ -22,7 +22,7 @@ # include <stdio.h> # include <stdint.h> -#define MD4_DIGEST_SIZE 16 +# define MD4_DIGEST_SIZE 16 /* Structure to save state of computation between the single steps. */ struct md4_ctx @@ -34,7 +34,7 @@ uint32_t total[2]; uint32_t buflen; - char buffer[128] __attribute__ ((__aligned__ (__alignof__ (uint32_t)))); + uint32_t buffer[128]; };