Menu

#91 Pointer Math (?)

OnBoard_Asm
open
nobody
5
2006-09-07
2006-09-07
Ken Mankoff
No

Please improve the Summary if someone has a better
understanding of this.

I have the following function. It will not compile.
This is not cut-and-pasted so please email me if you're
working on this bug and want help.

Boolean foo(const UTF8 *source, const UTF8 *sourceEnd) {
int length = bar[*source]+1;
if (source + length > sourceEnd) {
return false;
}
return true;
}

The error occurs on the source+length line. If I change
it to the following it does compile. I have yet to
completely verify this fix as valid.

Boolean foo(const UTF8 *source, const UTF8 *sourceEnd) {
int length = bar[*source]+1;
UTF8 *spl = source + length;
if ( spl > sourceEnd ) {
//if (source + length > sourceEnd) {
return false;
}
return true;
}

elsewhere: typedef UInt8 UTF8;

Discussion


Log in to post a comment.