summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-09-30 15:38:34 +0200
committerDaniel Kolesa <d.kolesa@samsung.com>2019-09-30 16:08:24 +0200
commit507061a145b8201f97e9ca8a269947174c3995ac (patch)
tree9651df8085dd4048ed87f1af92d1acaff29b8b2d /src/bin
parent62139f2292c9eb0136559fbc0f51300285f39e30 (diff)
bindings: Fix disposal of eolian state
Summary: It was actually leaking before. Let's use some RAII classes that were already there. ref T8280 Reviewers: q66, felipealmeida, brunobelo Reviewed By: q66 Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8280 Differential Revision: https://phab.enlightenment.org/D10237
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/eolian_cxx/eolian_cxx.cc20
-rw-r--r--src/bin/eolian_mono/eolian_mono.cc20
2 files changed, 7 insertions, 33 deletions
diff --git a/src/bin/eolian_cxx/eolian_cxx.cc b/src/bin/eolian_cxx/eolian_cxx.cc
index 6f719f1..636d1eb 100644
--- a/src/bin/eolian_cxx/eolian_cxx.cc
+++ b/src/bin/eolian_cxx/eolian_cxx.cc
@@ -40,10 +40,6 @@ struct options_type
40 bool main_header; 40 bool main_header;
41 41
42 options_type() : main_header(false) {} 42 options_type() : main_header(false) {}
43 ~options_type()
44 {
45 eolian_state_free(state);
46 }
47}; 43};
48 44
49static efl::eina::log_domain domain("eolian_cxx"); 45static efl::eina::log_domain domain("eolian_cxx");
@@ -386,19 +382,6 @@ run(options_type const& opts)
386} 382}
387 383
388static void 384static void
389state_init(options_type const& opts)
390{
391 Eolian_State *eos = ::eolian_state_new();
392 if (!eos)
393 {
394 EINA_CXX_DOM_LOG_ERR(eolian_cxx::domain)
395 << "Eolian failed creating state";
396 assert(false && "Error creating Eolian state");
397 }
398 opts.state = eos;
399}
400
401static void
402database_load(options_type const& opts) 385database_load(options_type const& opts)
403{ 386{
404 for (auto src : opts.include_dirs) 387 for (auto src : opts.include_dirs)
@@ -532,8 +515,9 @@ int main(int argc, char **argv)
532 { 515 {
533 efl::eina::eina_init eina_init; 516 efl::eina::eina_init eina_init;
534 efl::eolian::eolian_init eolian_init; 517 efl::eolian::eolian_init eolian_init;
518 efl::eolian::eolian_state eolian_state;
535 eolian_cxx::options_type opts = opts_get(argc, argv); 519 eolian_cxx::options_type opts = opts_get(argc, argv);
536 eolian_cxx::state_init(opts); 520 opts.state = eolian_state.value;
537 eolian_cxx::database_load(opts); 521 eolian_cxx::database_load(opts);
538 eolian_cxx::run(opts); 522 eolian_cxx::run(opts);
539 } 523 }
diff --git a/src/bin/eolian_mono/eolian_mono.cc b/src/bin/eolian_mono/eolian_mono.cc
index 83379b2..97996d9 100644
--- a/src/bin/eolian_mono/eolian_mono.cc
+++ b/src/bin/eolian_mono/eolian_mono.cc
@@ -173,6 +173,8 @@ run(options_type const& opts)
173 throw std::runtime_error("Failed to generate alias."); 173 throw std::runtime_error("Failed to generate alias.");
174 } 174 }
175 } 175 }
176 ::eina_iterator_free(aliases);
177
176 178
177 // Constants 179 // Constants
178 { 180 {
@@ -227,20 +229,6 @@ run(options_type const& opts)
227} 229}
228 230
229static void 231static void
230state_init(options_type const& opts)
231{
232 Eolian_State *eos = ::eolian_state_new();
233 if (!eos)
234 {
235 EINA_CXX_DOM_LOG_ERR(eolian_mono::domain)
236 << "Eolian failed creating state";
237 assert(false && "Error creating state");
238 }
239 opts.state = eos;
240 opts.unit = (Eolian_Unit*)eos;
241}
242
243static void
244database_load(options_type const& opts) 232database_load(options_type const& opts)
245{ 233{
246 for (auto src : opts.include_dirs) 234 for (auto src : opts.include_dirs)
@@ -420,8 +408,10 @@ int main(int argc, char **argv)
420 { 408 {
421 efl::eina::eina_init eina_init; 409 efl::eina::eina_init eina_init;
422 efl::eolian::eolian_init eolian_init; 410 efl::eolian::eolian_init eolian_init;
411 efl::eolian::eolian_state eolian_state;
423 eolian_mono::options_type opts = opts_get(argc, argv); 412 eolian_mono::options_type opts = opts_get(argc, argv);
424 eolian_mono::state_init(opts); 413 opts.state = eolian_state.value;
414 opts.unit = eolian_state.as_unit();
425 eolian_mono::database_load(opts); 415 eolian_mono::database_load(opts);
426 eolian_mono::run(opts); 416 eolian_mono::run(opts);
427 } 417 }