41 lines
2.4 KiB
Diff
41 lines
2.4 KiB
Diff
diff -ur jna-3.0.4-svn630/src/com/sun/jna/Structure.java jna-3.0.4-svn630.orig/src/com/sun/jna/Structure.java
|
|
--- jna-3.0.4-svn630/src/com/sun/jna/Structure.java 2008-09-05 21:49:16.000000000 -0400
|
|
+++ jna-3.0.4-svn630.orig/src/com/sun/jna/Structure.java 2008-09-06 17:43:34.000000000 -0400
|
|
@@ -612,28 +612,28 @@
|
|
|
|
// Set the value at the offset according to its type
|
|
if (nativeType == boolean.class || nativeType == Boolean.class) {
|
|
- memory.setInt(offset, Boolean.TRUE.equals(value) ? -1 : 0);
|
|
+ memory.setInt(offset, (value != null && Boolean.TRUE.equals(value)) ? -1 : 0);
|
|
}
|
|
else if (nativeType == byte.class || nativeType == Byte.class) {
|
|
- memory.setByte(offset, ((Byte)value).byteValue());
|
|
+ memory.setByte(offset, value != null ? ((Byte)value).byteValue() : 0);
|
|
}
|
|
else if (nativeType == short.class || nativeType == Short.class) {
|
|
- memory.setShort(offset, ((Short)value).shortValue());
|
|
+ memory.setShort(offset, value != null ? ((Short)value).shortValue() : 0);
|
|
}
|
|
else if (nativeType == char.class || nativeType == Character.class) {
|
|
- memory.setChar(offset, ((Character)value).charValue());
|
|
+ memory.setChar(offset, value != null ? ((Character)value).charValue() : '\0');
|
|
}
|
|
else if (nativeType == int.class || nativeType == Integer.class) {
|
|
- memory.setInt(offset, ((Integer)value).intValue());
|
|
+ memory.setInt(offset, value != null ? ((Integer)value).intValue() : 0);
|
|
}
|
|
else if (nativeType == long.class || nativeType == Long.class) {
|
|
- memory.setLong(offset, ((Long)value).longValue());
|
|
+ memory.setLong(offset, value != null ? ((Long)value).longValue() : 0);
|
|
}
|
|
else if (nativeType == float.class || nativeType == Float.class) {
|
|
- memory.setFloat(offset, ((Float)value).floatValue());
|
|
+ memory.setFloat(offset, value != null ? ((Float)value).floatValue() : 0.0f);
|
|
}
|
|
else if (nativeType == double.class || nativeType == Double.class) {
|
|
- memory.setDouble(offset, ((Double)value).doubleValue());
|
|
+ memory.setDouble(offset, value != null ? ((Double)value).doubleValue() : 0.0);
|
|
}
|
|
else if (nativeType == Pointer.class) {
|
|
memory.setPointer(offset, (Pointer)value);
|