Advertisement

Am i missing something here?

Started by June 04, 2000 11:24 AM
1 comment, last by OneEyeLessThanNone 24 years, 7 months ago
I can compile the following code but when I execute it kicks out. I''m guessing it''s a page fault but it doesn''t even give me any error windows so I can''t verify. The debugger seems to crash when ever i use it so thats useless. Am I missing something in this code or what?

int c_Image::draw( IMAGE *dest, IMAGE *source, int x, int y )
{
	unsigned short		*src, *dst;
	unsigned short		t, u, v, a;
	src = source->c;
	dst = dest->c;
	for( int i = 0; i < source->h; i++, dst += dest->w )
		for( int j = 0; j < source->w; j++, src++ )
		{
			t = *src;
>> crashes here >>	dst[j] = t;
		}

	return 0;
} // int c_Image::draw( IMAGE *dest, IMAGE *source, int x, int y )
 
It crashes where marked. but if i replace t with a constant or another variable, it doesn''t crash. OneEyeLessThanNone
I think that you''re running over the array''s boundaries. Try dst[j - 1] = t; and see if it works.

/. Muzzafarath
Mad House Software
I'm reminded of the day my daughter came in, looked over my shoulder at some Perl 4 code, and said, "What is that, swearing?" - Larry Wall
Advertisement
Thanks to the good people at the gamedev channel, ive been able to figure out my problem. My source array was out of bounds. However I blame the compiler optimizations for misleading me so.

OneEyeLessThanNone

This topic is closed to new replies.

Advertisement