]> rtime.felk.cvut.cz Git - orte.git/blob - orte/libjorte/JORTEDomainPropDestroy.c
JORTE: fix memory leak in jORTEDomainPropDefaultGet()
[orte.git] / orte / libjorte / JORTEDomainPropDestroy.c
1 #include <string.h>
2 #include <stdlib.h>
3 #include "orte.h"
4 #include "jorte/4all.h"
5
6 #include "jorte/org_ocera_orte_types_DomainProp.h"
7
8   JNIEXPORT jboolean JNICALL Java_org_ocera_orte_types_DomainProp_jORTEDomainPropDestroy
9   (
10    JNIEnv *env,
11    jobject obj,
12    jlong propshandle,        //ORTEDomainProp handle
13    jstring mgrs              //Managers
14   )
15   {
16     int flag_ok = 0;
17     ORTEDomainProp *dp = NULL;
18
19     #ifdef TEST_STAGE
20       printf(":c: jORTEDomainPropDestroy() called.. \n");
21     #endif
22
23     do {
24       dp = (ORTEDomainProp *) propshandle;
25       if(dp == 0) {
26         #ifdef TEST_STAGE
27           printf(":!c: *dp = NULL \n");
28         #endif
29         break;
30       }
31
32       //release fellow managers string
33       (*env)->ReleaseStringUTFChars(env,mgrs,dp->mgrs);
34
35       //free DomainProperties memory
36       free(dp);
37
38       flag_ok = 1;
39     } while (0);
40
41     if(flag_ok) {
42       return  ORTE_TRUE;
43     }
44
45     return ORTE_FALSE;
46   }