]> rtime.felk.cvut.cz Git - orte.git/commitdiff
JORTE: free() domain events
authorMartin Vajnar <martin.vajnar@gmail.com>
Tue, 23 Jul 2013 14:55:00 +0000 (16:55 +0200)
committerMartin Vajnar <martin.vajnar@gmail.com>
Tue, 23 Jul 2013 14:55:00 +0000 (16:55 +0200)
This fixes memory leak in jORTEDomainInitEvents() and removes unused code
from JOrte.java.

orte/include/jorte/org_ocera_orte_types_DomainEvents.h
orte/java/src/org/ocera/orte/DomainApp.java
orte/java/src/org/ocera/orte/DomainMgr.java
orte/java/src/org/ocera/orte/JOrte.java
orte/java/src/org/ocera/orte/types/DomainEvents.java
orte/libjorte/JORTEDomainEventsDestroy.c [new file with mode: 0644]
orte/libjorte/JORTEDomainInitEvents.c
orte/libjorte/Makefile.am
orte/libjorte/Makefile.omk

index 3a7219c48bb80fef4d1a0a48d5f791cb88f80180..810b8332b4a3c571e9dd807f4d63e8da7d80b495 100644 (file)
@@ -13,7 +13,15 @@ extern "C" {
  * Signature: ()J
  */
 JNIEXPORT jlong JNICALL Java_org_ocera_orte_types_DomainEvents_jORTEDomainInitEvents
-  (JNIEnv *, jclass);
+  (JNIEnv *, jobject);
+
+/*
+ * Class:     org_ocera_orte_types_DomainEvents
+ * Method:    jORTEDomainEventsDestroy
+ * Signature: (J)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_ocera_orte_types_DomainEvents_jORTEDomainEventsDestroy
+  (JNIEnv *, jobject, jlong);
 
 #ifdef __cplusplus
 }
index eccd2aff3831158150260855b45d6445149da0fc..771f5fe42cfebd89cde1cc632b5b6fb1effc15d2 100644 (file)
@@ -67,7 +67,9 @@ public class DomainApp extends Domain
    @Override
    public boolean destroy()
    {
-     if(destroyAllRegTypes() && jORTEDomainAppDestroy(this.handle) && (this.props == null || this.props.destroy())) return true;
+     if(destroyAllRegTypes() && jORTEDomainAppDestroy(this.handle)
+                && (this.props == null || this.props.destroy())
+                && (this.events == null || this.events.destroy())) return true;
      System.out.println(":j!: ORTEDomainAppDestroy() fault..");
      return false;
    }
index 13f01facffaa33b1bbae1511a7915a7ffdf7d888..1b6dde476d174f0af79ffe6a94d50e904df04019 100644 (file)
@@ -73,7 +73,9 @@ public class DomainMgr extends Domain
          public
          boolean destroy()
          {
-           if(jORTEDomainMgrDestroy(this.handle) && (this.props == null || this.props.destroy())) return true;
+           if(jORTEDomainMgrDestroy(this.handle)
+                       && (this.props == null || this.props.destroy())
+                       && (this.events == null || this.events.destroy())) return true;
            System.out.println(":j!: ORTEDomainMgrDestroy() fault..");
            return false;
          }
index bfaf9cf3219dc2cac146f1281fcb89f06d479a70..c3e4ae3351732d034c4409cf30fbb8a795a281e7 100644 (file)
@@ -51,13 +51,6 @@ public class JOrte {
     jORTEVerbositySetLogFile(logfile);
    }
 
-   public static
-   void appSendThread(long dhandle)
-   {
-    jORTEAppSendThread(dhandle);
-   }
-
-
 
   /* ****************************************************************** *
    *                                                                    *
@@ -106,15 +99,4 @@ public class JOrte {
    private static native
    void jORTEVerbositySetLogFile(String logfile);
 
-
-  /**
-   * jORTEVerbositySetLogFile -
-   *
-   *
-   * @return void
-   */
-   private static native
-   void jORTEAppSendThread(long dhandle);
-
-
 }
index a4295cc780e245ce8bc0ac93b997572b3c17545a..801ed004d0886fdaa302d12d24d97c9c13e8b9a7 100644 (file)
@@ -35,28 +35,30 @@ public abstract class DomainEvents {
   }
 
   public DomainEvents()
-  {
-       init();
-       System.out.println(":j: events created & initialized..");
-  }
-
-
-  /**
-   * Initializes DomainEvents and return their handle
-   * @return handle initialized DomainEvents
-   */
-  public void init()
   {
     this.handle = jORTEDomainInitEvents();
-       return;
+       System.out.println(":j: events created & initialized..");
   }
-
   
   public long getHandle()
   {
        return this.handle;
   }
   
+  public boolean destroy()
+  {
+    System.out.println(":j: DomainEvents destroy called..");
+
+    if(!jORTEDomainEventsDestroy(this.handle)) {
+      System.out.println(":j: DomainEvents destroy fault!");
+      return false;
+    }
+    else {
+      System.out.println(":j: DomainEvents destroy successful..");
+      return true;
+    }
+  }
+  
   public abstract void onRegFail();
   public abstract void onMgrNew(AppInfo appInfo);
   public abstract void onMgrDelete(AppInfo appInfo);
@@ -82,9 +84,9 @@ public abstract class DomainEvents {
   *
   * @return handler to default properties of a domain, NULL if error
   */
-  private static native
+  private native
   long jORTEDomainInitEvents();
 
-
-
+  private native
+  boolean jORTEDomainEventsDestroy(long handle);
 }
diff --git a/orte/libjorte/JORTEDomainEventsDestroy.c b/orte/libjorte/JORTEDomainEventsDestroy.c
new file mode 100644 (file)
index 0000000..b9dda00
--- /dev/null
@@ -0,0 +1,20 @@
+#include <stdlib.h>
+// origin orte headers
+#include "orte.h"
+// pregenerated header
+#include "jorte/org_ocera_orte_types_DomainEvents.h"
+#include "jorte/4all.h"
+#include "jorte/jorte_typedefs_defines.h"
+
+JNIEXPORT jboolean JNICALL
+Java_org_ocera_orte_types_DomainEvents_jORTEDomainEventsDestroy
+(JNIEnv *env, jobject obj, jlong handle)
+{
+  free((void*)handle);
+
+  #ifdef TEST_STAGE
+     printf(":c: events destroyed.. \n");
+  #endif
+
+  return 1;
+}
index 4ec2f37f604f52b843589444cb581dd1296edae8..3bd004f75532b33094ef76d90413500c20c354fb 100644 (file)
@@ -36,7 +36,7 @@
 
 JNIEXPORT jlong JNICALL
 Java_org_ocera_orte_types_DomainEvents_jORTEDomainInitEvents
-(JNIEnv *env, jclass cls)
+(JNIEnv *env, jobject obj)
 {
   ORTEDomainAppEvents *evs;
 
index cbb9c30fa6117929b6d24ee42db480d51d5b6257..1e168bedfa52f56caa24ef84e4b89e59b21799f5 100644 (file)
@@ -13,6 +13,8 @@ JNtpTimeToStringMs.c \
 JNtpTimeToStringUs.c \
 JORTEDomainAppCreate.c \
 JORTEDomainAppDestroy.c \
+JORTEDomainEvents.c \
+JORTEDomainEventsDestroy.c \
 JORTEDomainInitEvents.c \
 JORTEDomainMgrCreate.c \
 JORTEDomainMgrDestroy.c \
index 7f1de70f1ca08407de4de3855e2a0066c318be3a..ea20e4833e9483f442f5cac70345b3ea532fe78f 100644 (file)
@@ -30,6 +30,7 @@ JNtpTimeToStringUs.c \
 JORTEDomainAppCreate.c \
 JORTEDomainAppDestroy.c \
 JORTEDomainEvents.c \
+JORTEDomainEventsDestroy.c \
 JORTEDomainInitEvents.c \
 JORTEDomainMgrCreate.c \
 JORTEDomainMgrDestroy.c \