cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=805128dbf38483ae6bd9ef531b4e002d564ca391

commit 805128dbf38483ae6bd9ef531b4e002d564ca391
Author: Cedric BAIL <cedric.b...@free.fr>
Date:   Thu Apr 18 09:28:31 2019 -0700

    eina: allow copy of EINA_VALUE_EMPTY type.
    
    This is usefule to allow timeout future to be propagated through 
eina_future_all
    or eina_future_race for example.
    
    Reviewed-by: Xavi Artigas <xavierarti...@yahoo.es>
    Differential Revision: https://phab.enlightenment.org/D8655
---
 src/lib/eina/eina_value.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/lib/eina/eina_value.c b/src/lib/eina/eina_value.c
index dbf6f48d9c..c75a5f1235 100644
--- a/src/lib/eina/eina_value.c
+++ b/src/lib/eina/eina_value.c
@@ -58,6 +58,7 @@ static Eina_Hash *_eina_value_inner_mps = NULL;
 static Eina_Lock _eina_value_inner_mps_lock;
 static char *_eina_value_mp_choice = NULL;
 static int _eina_value_log_dom = -1;
+static const Eina_Value _eina_value_empty = EINA_VALUE_EMPTY;
 
 #ifdef ERR
 #undef ERR
@@ -3954,6 +3955,7 @@ _eina_value_type_value_vset(const Eina_Value_Type *type 
EINA_UNUSED, void *mem,
 {
    Eina_Value *dst = mem;
    Eina_Value src = va_arg(args, Eina_Value);
+
    return eina_value_copy(&src, dst);
 }
 
@@ -3962,6 +3964,7 @@ _eina_value_type_value_pset(const Eina_Value_Type *type 
EINA_UNUSED, void *mem,
 {
    Eina_Value *dst = mem;
    const Eina_Value *src = ptr;
+
    return eina_value_copy(src, dst);
 }
 
@@ -5591,9 +5594,7 @@ eina_value_new(const Eina_Value_Type *type)
    if (!value) return NULL;
    if (!type)
      {
-        const Eina_Value empty = EINA_VALUE_EMPTY;
-
-        memcpy(value, &empty, sizeof (empty));
+        memcpy(value, &_eina_value_empty, sizeof (_eina_value_empty));
         return value;
      }
    if (!eina_value_setup(value, type))
@@ -5622,6 +5623,13 @@ eina_value_copy(const Eina_Value *value, Eina_Value 
*copy)
    Eina_Bool ret;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
+
+   if (!memcmp(value, &_eina_value_empty, sizeof (Eina_Value)))
+     {
+        memcpy(copy, &_eina_value_empty, sizeof (Eina_Value));
+        return EINA_TRUE;
+     }
+
    EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(value->type),
                                    EINA_FALSE);
    EINA_SAFETY_ON_NULL_RETURN_VAL(copy, EINA_FALSE);

-- 


Reply via email to