Zajcev Evgeny <zevlg(a)yandex.ru> writes:
[snip]
void
cptr2(void *ptr, unsigned int len)
{
while (len-- > 0) {
char a = ((char*)ptr)[len];
if (a == '1')
((char*)ptr)[len] = a;
}
}
Oh, my bad. I realized that this will not work for XEmacs, only after
sending mail. PTR may lay in read only segment and writing to it will
eventually lead to SIGBUS.
So here is another variant:
void
cptr2(void *ptr, unsigned int len)
{
static char dummy_char;
while (len-- > 0)
dummy_char = ((char*)ptr)[len];
}
Checked with gcc295 and gcc342, works with and without optimisation
flags.
--
lg