From 07899a942fc46a5d75b4cd2360692592d2e2a1e7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Thu, 23 Oct 2008 12:54:02 +0000 Subject: [PATCH] Leak fixing hacks. --- org.glite.lb.common/Makefile | 2 +- org.glite.lb.common/src/events_parse.c.T | 2 ++ org.glite.lb.common/src/xml_parse.c.T | 10 +++++++--- org.glite.lb.common/test/il_int_test.cpp | 2 +- org.glite.lb.common/test/parse.cpp.T | 7 ++++++- org.glite.lb.common/test/test_main.cpp | 4 ++++ org.glite.lb.types/types.T | 4 ++-- 7 files changed, 23 insertions(+), 8 deletions(-) diff --git a/org.glite.lb.common/Makefile b/org.glite.lb.common/Makefile index 02b02bb..d55c727 100644 --- a/org.glite.lb.common/Makefile +++ b/org.glite.lb.common/Makefile @@ -174,7 +174,7 @@ mkreports: check.parse: test_parse ./test_parse ${REPORTS}/parse.xml -test_parse: parse.o +test_parse: parse.o test_main.cpp ${LINKXX} -o test_parse parse.o ${LTLIB} ${TEST_LIBS} ${EXT_LIBS} check.il: il_test diff --git a/org.glite.lb.common/src/events_parse.c.T b/org.glite.lb.common/src/events_parse.c.T index b3a5788..e80aee4 100644 --- a/org.glite.lb.common/src/events_parse.c.T +++ b/org.glite.lb.common/src/events_parse.c.T @@ -432,6 +432,8 @@ edg_wll_ErrorCode edg_wll_CompareEvents( const edg_wll_Event *e2 /* event 2 IN */ ) { + char *tmp1, *tmp2; + int tmp3; if (e1->any.type != e2->any.type) return edg_wll_SetError(context,EDG_WLL_ERROR_COMPARE_EVENTS,"Different event types"); @@@{ selectType $event '_common_'; diff --git a/org.glite.lb.common/src/xml_parse.c.T b/org.glite.lb.common/src/xml_parse.c.T index 5c47b2c..6a3dddc 100644 --- a/org.glite.lb.common/src/xml_parse.c.T +++ b/org.glite.lb.common/src/xml_parse.c.T @@ -2870,13 +2870,15 @@ int edg_wll_NotifRequestToXML( int flags, char **message) { - char *pomA=NULL, *pomB=NULL, *pomC=NULL, *cflags=NULL; + char *pomA=NULL, *pomB=NULL, *pomC=NULL, *cflags=NULL, *nid=NULL, *nop=NULL; pomA = strdup(""); - edg_wll_add_string_to_XMLBody(&pomA, edg_wll_NotifIdUnparse(notifId), "notifId", NULL); + nid = edg_wll_NotifIdUnparse(notifId); + nop = edg_wll_NotifChangeOpToString(op); + edg_wll_add_string_to_XMLBody(&pomA, nid, "notifId", NULL); edg_wll_add_string_to_XMLBody(&pomA, address, "clientAddress", NULL); - edg_wll_add_string_to_XMLBody(&pomA, edg_wll_NotifChangeOpToString(op), "notifChangeOp", NULL); + edg_wll_add_string_to_XMLBody(&pomA, nop, "notifChangeOp", NULL); edg_wll_add_time_t_to_XMLBody(&pomA, validity, "requestedValidity", -1); if (conditions && conditions[0] && conditions[0][0].attr != EDG_WLL_QUERY_ATTR_UNDEF) edg_wll_JobQueryRecToXML(ctx, conditions, &pomB); @@ -2891,6 +2893,8 @@ int edg_wll_NotifRequestToXML( free(cflags); + free(nid); + free(nop); free(pomA); free(pomB); *message = pomC; diff --git a/org.glite.lb.common/test/il_int_test.cpp b/org.glite.lb.common/test/il_int_test.cpp index f547019..2ed6a83 100644 --- a/org.glite.lb.common/test/il_int_test.cpp +++ b/org.glite.lb.common/test/il_int_test.cpp @@ -26,7 +26,7 @@ public: void testPutInt() { put_int(buffer, 17); - CPPUNIT_ASSERT(!strcmp(buffer, "17\n")); + CPPUNIT_ASSERT(!strncmp(buffer, "17\n", 3)); } void testGetInt() { diff --git a/org.glite.lb.common/test/parse.cpp.T b/org.glite.lb.common/test/parse.cpp.T index e5cd14a..d8c7e9b 100644 --- a/org.glite.lb.common/test/parse.cpp.T +++ b/org.glite.lb.common/test/parse.cpp.T @@ -59,7 +59,7 @@ void EventParseTest::$l() e1->any.level = 7; e1->any.priority = 0; edg_wlc_JobIdParse("https://some.host:1234/x67qr549qc",&e1->any.jobId); - e1->any.seqcode = EDG_WLL_SEQ_BIGHELPER_INITIAL; + e1->any.seqcode = strdup(EDG_WLL_SEQ_BIGHELPER_INITIAL); e1->any.user = strdup("/O=Grid/CN=This User"); e1->any.source = EDG_WLL_SOURCE_USER_INTERFACE; e1->any.src_instance = strdup(""); @@ -117,6 +117,11 @@ void EventParseTest::$l() edg_wll_Error(ctx,&et,&ed); CPPUNIT_ASSERT_MESSAGE(std::string("edg_wll_CompareEvents():") + et + " " + ed, 0); } + + edg_wll_FreeEvent(e1); free(e1); + edg_wll_FreeEvent(e2); free(e2); + edg_wll_FreeContext(ctx); + free(line); } '; diff --git a/org.glite.lb.common/test/test_main.cpp b/org.glite.lb.common/test/test_main.cpp index b2f6fdd..43ebc57 100644 --- a/org.glite.lb.common/test/test_main.cpp +++ b/org.glite.lb.common/test/test_main.cpp @@ -8,6 +8,8 @@ #include #include +#include + int main (int argc,const char *argv[]) { CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); @@ -28,5 +30,7 @@ int main (int argc,const char *argv[]) xout.write(); tout.write(); + edg_wll_poolFree(); + return result.wasSuccessful() ? 0 : 1 ; } diff --git a/org.glite.lb.types/types.T b/org.glite.lb.types/types.T index fee3817..cc10e81 100644 --- a/org.glite.lb.types/types.T +++ b/org.glite.lb.types/types.T @@ -144,9 +144,9 @@ string=>'if ($b eq \'NULL\') { qq{(($a) == NULL)}; } else { qq{(($a) == NULL && ($b) == NULL) || (($a)&&($b)&& !strcmp($a,$b))}; } ', jobid=>'if ($b eq \'NULL\') { qq{(($a) == NULL) }; } - else { qq{(($a) == NULL && ($b) == NULL) || (($a)&&($b)&& !strcmp(edg_wlc_JobIdUnparse($a),edg_wlc_JobIdUnparse($b)))}; }', + else { qq{(($a) == NULL && ($b) == NULL) || (($a)&&($b)&& !(tmp1=glite_jobid_unparse($a),tmp2=glite_jobid_unparse($b),tmp3=strcmp(tmp1,tmp2),free(tmp1),free(tmp2),tmp3))}; }', notifid=>'if ($b eq \'NULL\') { qq{(($a) == NULL) }; } - else { qq{(($a) == NULL && ($b) == NULL) || (($a)&&($b)&& !strcmp(edg_wll_NotifIdUnparse($a),edg_wll_NotifIdUnparse($b)))}; }', + else { qq{(($a) == NULL && ($b) == NULL) || (($a)&&($b)&& !(tmp1=edg_wll_NotifIdUnparse($a),tmp2=edg_wll_NotifIdUnparse($b),tmp3=strcmp(tmp1,tmp2),free(tmp1),free(tmp2),tmp3))}; }', logsrc=>'"($a) == ($b)"', timeval=>'"($a).tv_sec == ($b).tv_sec && ($a).tv_usec == ($b).tv_usec"', cclassad=>'"($a == $b)"', -- 1.8.2.3