Only keep the original structure if its native address is unchanged. Otherwise replace it with a new object. @param type Structure subclass @param s Original Structure object @param address the native struct @return Updated Structure.ByReference object
(Class<T> type, T s, Pointer address)
| 693 | * @return Updated <code>Structure.ByReference</code> object |
| 694 | */ |
| 695 | static <T extends Structure> T updateStructureByReference(Class<T> type, T s, Pointer address) { |
| 696 | if (address == null) { |
| 697 | s = null; |
| 698 | } |
| 699 | else { |
| 700 | if (s == null || !address.equals(s.getPointer())) { |
| 701 | Structure s1 = reading().get(address); |
| 702 | if (s1 != null && type.equals(s1.getClass())) { |
| 703 | s = (T) s1; |
| 704 | s.autoRead(); |
| 705 | } |
| 706 | else { |
| 707 | s = newInstance(type, address); |
| 708 | s.conditionalAutoRead(); |
| 709 | } |
| 710 | } |
| 711 | else { |
| 712 | s.autoRead(); |
| 713 | } |
| 714 | } |
| 715 | return s; |
| 716 | } |
| 717 | |
| 718 | /** Read the given field and return its value. The Java field will be |
| 719 | * updated from the contents of native memory. |
no test coverage detected