From: Marcus Comstedt Date: Sun, 1 Nov 2015 14:59:47 +0000 (+0100) Subject: Java: Fill jlongs with 0 when doing SWIG style pointer marshalling X-Git-Tag: libsigrok-0.4.0~130 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=908aad38164869c2ecf066a73962a3864c644587;p=libsigrok.git Java: Fill jlongs with 0 when doing SWIG style pointer marshalling This prevents valgrind complaints and also makes pointer comparison from the Java side work. --- diff --git a/bindings/java/org/sigrok/core/classes/classes.i b/bindings/java/org/sigrok/core/classes/classes.i index 5a020d7e..894c72f7 100644 --- a/bindings/java/org/sigrok/core/classes/classes.i +++ b/bindings/java/org/sigrok/core/classes/classes.i @@ -72,7 +72,7 @@ namespace Glib { jclass Value = jenv->FindClass("org/sigrok/core/classes/" #JValue); jmethodID Value_init = jenv->GetMethodID(Value, "", "(JZ)V"); $result = jenv->NewObject(Vector, Vector_init); - jlong value; + jlong value = 0; for (auto entry : $1) { *(CValue **) &value = new CValue(entry); @@ -146,7 +146,7 @@ MAP_COMMON(std::string, std::shared_ptr, String, ClassName) jclass Value = jenv->FindClass("org/sigrok/core/classes/" #ClassName); jmethodID Value_init = jenv->GetMethodID(Value, "", "(JZ)V"); $result = jenv->NewObject(HashMap, HashMap_init); - jlong value; + jlong value = 0; for (auto entry : $1) { *(std::shared_ptr< sigrok::ClassName > **)&value = @@ -181,8 +181,8 @@ MAP_COMMON(const sigrok::ConfigKey *, Glib::VariantBase, ConfigKey, Variant) jclass Variant = jenv->FindClass("org/sigrok/core/classes/Variant"); jmethodID Variant_init = jenv->GetMethodID(Variant, "", "(JZ)V"); $result = jenv->NewObject(HashMap, HashMap_init); - jlong key; - jlong value; + jlong key = 0; + jlong value = 0; for (auto entry : $1) { *(const sigrok::ConfigKey **) &key = entry.first; @@ -217,7 +217,7 @@ MAP_COMMON(const sigrok::ConfigKey *, std::set, jmethodID Capability_swigToEnum = jenv->GetStaticMethodID(Capability, "swigToEnum", "(I)Lorg/sigrok/core/classes/Capability;"); $result = jenv->NewObject(HashMap, HashMap_init); - jlong key; + jlong key = 0; for (auto map_entry : $1) { *(const sigrok::ConfigKey **) &key = map_entry.first; @@ -267,7 +267,7 @@ typedef jobject jlogcallback; const sigrok::LogLevel *loglevel, std::string message) { - jlong loglevel_addr; + jlong loglevel_addr = 0; *(const sigrok::LogLevel **) &loglevel_addr = loglevel; jobject loglevel_obj = env->NewObject( LogLevel, LogLevel_init, loglevel_addr, false); @@ -312,8 +312,8 @@ typedef jobject jdatafeedcallback; std::shared_ptr device, std::shared_ptr packet) { - jlong device_addr; - jlong packet_addr; + jlong device_addr = 0; + jlong packet_addr = 0; *(std::shared_ptr **) &device_addr = new std::shared_ptr(device); *(std::shared_ptr **) &packet_addr =