Index: [thread] [date] [subject] [author]
  From: Andreas Beck <becka@rz.uni-duesseldorf.de>
  To  : ggi-develop@eskimo.com
  Date: Mon, 17 May 1999 00:19:26 +0200

Re: Semi-Snag in PyGGI...

> > Yes, the increment is fine.
> > But for the assignment you are casting the pointer to ggi_pixel* instead
> > of to a pointer to the actual pixel size.
> How interesting...
> So is there no way to do it without some sort of switch() on display
> depth?

Maybe one should explain, why it is bad to make something like

char *ptr;
ptr+=increment
*(int *)ptr=something

There are two main implications you should be aware of:

1. You will overflow the buffer by (sizeof(accessed-size)-sizeof(inc_size)).
That's a minor issue, as you can just alloc it a little bigger.

2. Non-Intel architectures will often have _heavy_ penalties for unaligned
access. Thus doing 32-bit wide accesses at increments of 1 byte will cause
3 such accesses per one aligned access.
Some architectures will sefgault/sigbus right away, while others will try
to compensate. On the Alpha for example, it will lead to an exception
that will then analyze the code that caused the fault and emulate it.
It will crawl.

If you want to do it without a switch, you'll have to resort to bytewise
copy, which is suboptimal as well.

CU, Andy

-- 
= Andreas Beck                    |  Email :  <andreas.beck@ggi-project.org> =

Index: [thread] [date] [subject] [author]