Hello, I have some fixes/questions/ideas about Mono.DataConverter.cs
1 -
On line 1229/1230 and 1239/1240 on PutBytesLE and PutBytesBE:
for (; i < count; i++)
dest [i-count] = *src++;
This starts putting data on an address that does not belong to the
pointer (a negative value), crashes mono (on Linux), and makes it
return a wrong value on Microsoft .net 2.0.
I changed it to:
dest = &dest [count-1];
for (; i < count; i++)
*dest-- = *src++;
Don't know if it is the best way, but I attached a patch.
2 -
It doesn't compile on Microsoft .net 2.0 because of the definition of
the var n inside the switch statements on lines 482 and 708, and
"fixed (byte* target = (&dest[destIdx]))" on line 974.
The last error goes away if you use "fixed (byte* target =
&dest[destIdx])" like it is used in the other overloaded PutBytes
methods, and I don't see any problem with that.
The declaration of var n could be done before entering the switch
statement, but I don't know if it is the best way. I can just compile
it with mono on Linux, and use it on MS .net so I guess this isn't
very problematic, at least for me, but if you want I can do some tests
and submit a patch.
3 -
Any problems on having the XXXFromXE (byte [] data, int index) methods
overloaded with an index of always 0? I'm not sure if there is a good
reason for it not being there, but if there is none, and you are OK
with it, I can also do it and submit a patch.
Thanks for your time, and keep up the good work,
Luis Gomes.
Index: DataConverter.cs
===================================================================
--- DataConverter.cs (revision 78241)
+++ DataConverter.cs (working copy)
@@ -1226,8 +1226,9 @@
for (; i < count; i++)
*dest++ = *src++;
} else {
+ dest = &dest [count-1];
for (; i < count; i++)
- dest [i-count] = *src++;
+ *dest-- = *src++;
}
}
@@ -1236,8 +1237,9 @@
int i = 0;
if (BitConverter.IsLittleEndian){
+ dest = &dest [count-1];
for (; i < count; i++)
- dest [i-count] = *src++;
+ *dest-- = *src++;
} else {
for (; i < count; i++)
*dest++ = *src++;
_______________________________________________
Mono-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list