MCPcopy Index your code
hub / github.com/java-native-access/jna / toArray

Method toArray

src/com/sun/jna/Structure.java:1711–1735  ·  view source on GitHub ↗

Returns a view of this structure's memory as an array of structures. Note that this Structure must have a public, no-arg constructor. If the structure is currently using auto-allocated Memory backing, the memory will be resized to fit the entire array. @param array Structure[]

(Structure[] array)

Source from the content-addressed store, hash-verified

1709 * @return array of Structure mapped onto the available memory
1710 */
1711 public Structure[] toArray(Structure[] array) {
1712 ensureAllocated();
1713 if (this.memory instanceof AutoAllocated) {
1714 // reallocate if necessary
1715 Memory m = (Memory)this.memory;
1716 int requiredSize = array.length * size();
1717 if (m.size() < requiredSize) {
1718 useMemory(autoAllocate(requiredSize));
1719 }
1720 }
1721 // TODO: optimize - check whether array already exists
1722 array[0] = this;
1723 int size = size();
1724 for (int i=1;i < array.length;i++) {
1725 array[i] = newInstance(getClass(), memory.share(i*size, size));
1726 array[i].conditionalAutoRead();
1727 }
1728
1729 if (!(this instanceof ByValue)) {
1730 // keep track for later auto-read/writes
1731 this.array = array;
1732 }
1733
1734 return array;
1735 }
1736
1737 /** Returns a view of this structure's memory as an array of structures.
1738 * Note that this <code>Structure</code> must have a public, no-arg

Callers 15

readArrayMethod · 0.95
writeArrayMethod · 0.95
getToListMethod · 0.45
getToListMethod · 0.45
callbackMethod · 0.45
testClearOnAllocateMethod · 0.45
TestStructureClass · 0.45

Calls 8

ensureAllocatedMethod · 0.95
sizeMethod · 0.95
sizeMethod · 0.95
useMemoryMethod · 0.95
autoAllocateMethod · 0.95
newInstanceMethod · 0.95
conditionalAutoReadMethod · 0.80
shareMethod · 0.45