We need to free the char* entries of the result array returned ourselves.
Signed-off-by: Claudio Bley <cbley(a)av-test.de>
---
src/main/java/org/libvirt/Domain.java | 14 +++++++-------
src/main/java/org/libvirt/jna/Libvirt.java | 2 +-
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/libvirt/Domain.java
b/src/main/java/org/libvirt/Domain.java
index 6db8745..39cb7c5 100644
--- a/src/main/java/org/libvirt/Domain.java
+++ b/src/main/java/org/libvirt/Domain.java
@@ -1186,15 +1186,15 @@ public class Domain {
* @throws LibvirtException
*/
public String[] snapshotListNames(int flags) throws LibvirtException {
- String[] returnValue = null;
int num = snapshotNum();
- if (num >= 0) {
- returnValue = new String[num];
- if (num > 0) {
- processError(libvirt.virDomainSnapshotListNames(VDP, returnValue, num,
flags));
- }
+ if (num > 0) {
+ Pointer[] ptrs = new Pointer[num];
+ int got = processError(libvirt.virDomainSnapshotListNames(VDP, ptrs, num,
flags));
+
+ return Library.toStringArray(ptrs, got);
+ } else {
+ return Library.NO_STRINGS;
}
- return returnValue;
}
/**
diff --git a/src/main/java/org/libvirt/jna/Libvirt.java
b/src/main/java/org/libvirt/jna/Libvirt.java
index bf3291d..5666c66 100644
--- a/src/main/java/org/libvirt/jna/Libvirt.java
+++ b/src/main/java/org/libvirt/jna/Libvirt.java
@@ -382,7 +382,7 @@ public interface Libvirt extends Library {
int virDomainSnapshotDelete(DomainSnapshotPointer virDomainSnapshotPtr, int flags);
String virDomainSnapshotGetXMLDesc(DomainSnapshotPointer virDomainSnapshotPtr, int
flags);
int virDomainSnapshotFree(DomainSnapshotPointer virDomainSnapshotPtr);
- int virDomainSnapshotListNames(DomainPointer virDomainPtr, String[] names, int
nameslen, int flags);
+ int virDomainSnapshotListNames(DomainPointer virDomainPtr, Pointer[] names, int
nameslen, int flags);
DomainSnapshotPointer virDomainSnapshotLookupByName(DomainPointer virDomainPtr,
String name, int flags);
int virDomainSnapshotNum(DomainPointer virDomainPtr, int flags);
--
1.7.9.5