diff options
author | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2019-09-10 17:29:01 +0100 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2019-09-10 17:44:51 +0100 |
commit | e51699afbc6094fcfc0f62ca2071ae7b8c6e313b (patch) | |
tree | d0c384bf3c1ef00901425207ad7fad8bdcddf8a6 | |
parent | 38be95b0b6fd93df01636ae0a7c974b32ed694a1 (diff) |
efl core cmommand line - implement destructor and thus fix leak
-rw-r--r-- | src/lib/ecore/efl_core_command_line.c | 19 | ||||
-rw-r--r-- | src/lib/ecore/efl_core_command_line.eo | 5 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/lib/ecore/efl_core_command_line.c b/src/lib/ecore/efl_core_command_line.c index 64de7a9766..f63d0dbbd2 100644 --- a/src/lib/ecore/efl_core_command_line.c +++ b/src/lib/ecore/efl_core_command_line.c | |||
@@ -203,6 +203,16 @@ _remove_invalid_chars(char *command) | |||
203 | } | 203 | } |
204 | } | 204 | } |
205 | 205 | ||
206 | static void | ||
207 | _clear_command(Efl_Core_Command_Line_Data *pd) | ||
208 | { | ||
209 | if (!pd->command) return; | ||
210 | while (eina_array_count(pd->command) > 0) | ||
211 | eina_stringshare_del(eina_array_pop(pd->command)); | ||
212 | eina_array_free(pd->command); | ||
213 | pd->command = NULL; | ||
214 | } | ||
215 | |||
206 | EOLIAN static Eina_Bool | 216 | EOLIAN static Eina_Bool |
207 | _efl_core_command_line_command_array_set(Eo *obj EINA_UNUSED, Efl_Core_Command_Line_Data *pd, Eina_Array *array) | 217 | _efl_core_command_line_command_array_set(Eo *obj EINA_UNUSED, Efl_Core_Command_Line_Data *pd, Eina_Array *array) |
208 | { | 218 | { |
@@ -210,6 +220,7 @@ _efl_core_command_line_command_array_set(Eo *obj EINA_UNUSED, Efl_Core_Command_L | |||
210 | Eina_Strbuf *command = eina_strbuf_new(); | 220 | Eina_Strbuf *command = eina_strbuf_new(); |
211 | unsigned int i = 0; | 221 | unsigned int i = 0; |
212 | 222 | ||
223 | _clear_command(pd); | ||
213 | pd->command = eina_array_new(array ? eina_array_count(array) : 0); | 224 | pd->command = eina_array_new(array ? eina_array_count(array) : 0); |
214 | for (i = 0; i < (array ? eina_array_count(array) : 0); ++i) | 225 | for (i = 0; i < (array ? eina_array_count(array) : 0); ++i) |
215 | { | 226 | { |
@@ -219,7 +230,6 @@ _efl_core_command_line_command_array_set(Eo *obj EINA_UNUSED, Efl_Core_Command_L | |||
219 | 230 | ||
220 | if (!param) | 231 | if (!param) |
221 | { | 232 | { |
222 | free(param); | ||
223 | while (eina_array_count(pd->command) > 0) | 233 | while (eina_array_count(pd->command) > 0) |
224 | eina_stringshare_del(eina_array_pop(pd->command)); | 234 | eina_stringshare_del(eina_array_pop(pd->command)); |
225 | eina_array_free(pd->command); | 235 | eina_array_free(pd->command); |
@@ -276,4 +286,11 @@ _efl_core_command_line_command_string_set(Eo *obj EINA_UNUSED, Efl_Core_Command_ | |||
276 | return EINA_TRUE; | 286 | return EINA_TRUE; |
277 | } | 287 | } |
278 | 288 | ||
289 | EOLIAN static void | ||
290 | _efl_core_command_line_efl_object_destructor(Eo *obj EINA_UNUSED, Efl_Core_Command_Line_Data *pd) | ||
291 | { | ||
292 | free(pd->string_command); | ||
293 | pd->string_command = NULL; | ||
294 | _clear_command(pd); | ||
295 | } | ||
279 | #include "efl_core_command_line.eo.c" | 296 | #include "efl_core_command_line.eo.c" |
diff --git a/src/lib/ecore/efl_core_command_line.eo b/src/lib/ecore/efl_core_command_line.eo index 6a7511d9ad..6eec372954 100644 --- a/src/lib/ecore/efl_core_command_line.eo +++ b/src/lib/ecore/efl_core_command_line.eo | |||
@@ -1,4 +1,4 @@ | |||
1 | mixin @beta Efl.Core.Command_Line { | 1 | mixin @beta Efl.Core.Command_Line requires Efl.Object { |
2 | [[A mixin that implements standard functions for command lines. | 2 | [[A mixin that implements standard functions for command lines. |
3 | 3 | ||
4 | This object parses the command line that gets passed, later the object can be accessed via accessor or the string | 4 | This object parses the command line that gets passed, later the object can be accessed via accessor or the string |
@@ -79,4 +79,7 @@ mixin @beta Efl.Core.Command_Line { | |||
79 | 79 | ||
80 | } | 80 | } |
81 | } | 81 | } |
82 | implements { | ||
83 | Efl.Object.destructor; | ||
84 | } | ||
82 | } | 85 | } |