From cc809bcbe6970515833971e725f510012d9f04e6 Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 29 Jun 2000 07:59:40 +0000 Subject: [PATCH] fixed an ugly bug that caused some unaligned access on 64-bits platforms.. Thnks a lot to Tom !! --- demos/graph/x11/grx11.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/demos/graph/x11/grx11.c b/demos/graph/x11/grx11.c index 8ca4f7f08..65f06da98 100644 --- a/demos/graph/x11/grx11.c +++ b/demos/graph/x11/grx11.c @@ -425,11 +425,23 @@ byte* _read = read; byte* limit = _write + 4*w; - for ( ; _write < limit; _write += 4, _read++ ) + if (sizeof(long) > 4) { - byte color = *_read; - - *(unsigned long*)_write = surface->color[color].pixel; + for ( ; _write < limit; _write += 4, _read++ ) + { + byte color = *_read; + + *(unsigned int*)_write = surface->color[color].pixel; + } + } + else + { + for ( ; _write < limit; _write += 4, _read++ ) + { + byte color = *_read; + + *(unsigned long*)_write = surface->color[color].pixel; + } } write += target->pitch;