summaryrefslogtreecommitdiff
path: root/src/lib/eio
diff options
context:
space:
mode:
authorCedric Bail <cedric@osg.samsung.com>2017-09-28 18:22:32 -0700
committerCedric Bail <cedric@osg.samsung.com>2017-09-28 18:31:34 -0700
commitc549f2c99377eda988676b0eb0d04117101b19a8 (patch)
treedbad39eff4c01e8d19c635c5b819e2ff7670a024 /src/lib/eio
parent961c860d65fd8f24b709ea8266ca4d80bd70aec5 (diff)
eio: do not copy memory for nothing.
Diffstat (limited to 'src/lib/eio')
-rw-r--r--src/lib/eio/efl_io_manager.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/lib/eio/efl_io_manager.c b/src/lib/eio/efl_io_manager.c
index e0c93186c6..4d832dffc5 100644
--- a/src/lib/eio/efl_io_manager.c
+++ b/src/lib/eio/efl_io_manager.c
@@ -417,18 +417,11 @@ EINA_VALUE_STRUCT_DESC_DEFINE(_eina_stat_desc,
417 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_ULONG, Eina_Stat, ctimensec)); 417 EINA_VALUE_STRUCT_MEMBER(EINA_VALUE_TYPE_ULONG, Eina_Stat, ctimensec));
418 418
419static void 419static void
420_file_stat_done_cb(void *data, Eio_File *handle EINA_UNUSED, const Eina_Stat *stat) 420_file_stat_done_cb(void *data, Eio_File *handle EINA_UNUSED, const Eina_Stat *st)
421{ 421{
422 Eina_Value_Struct value = { _eina_stat_desc(), NULL }; 422 const Eina_Value_Struct value = { _eina_stat_desc(), (void*) st };
423 Eina_Promise *p = data; 423 Eina_Promise *p = data;
424 Eina_Value r = EINA_VALUE_EMPTY; 424 Eina_Value r = EINA_VALUE_EMPTY;
425 Eina_Stat *cpy = NULL;
426
427 cpy = calloc(1, sizeof (Eina_Stat));
428 if (!cpy) goto on_error;
429
430 memcpy(cpy, stat, sizeof (Eina_Stat));
431 value.memory = cpy;
432 425
433 if (!eina_value_setup(&r, EINA_VALUE_TYPE_STRUCT)) 426 if (!eina_value_setup(&r, EINA_VALUE_TYPE_STRUCT))
434 goto on_error; 427 goto on_error;
@@ -440,7 +433,6 @@ _file_stat_done_cb(void *data, Eio_File *handle EINA_UNUSED, const Eina_Stat *st
440 return ; 433 return ;
441 434
442 on_error: 435 on_error:
443 free(cpy);
444 eina_value_flush(&r); 436 eina_value_flush(&r);
445 eina_promise_reject(p, eina_error_get()); 437 eina_promise_reject(p, eina_error_get());
446} 438}