barbieri pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=4da53492ae1235a728d1335fdc7e3cc214df9763

commit 4da53492ae1235a728d1335fdc7e3cc214df9763
Author: Gustavo Sverzut Barbieri <[email protected]>
Date:   Wed Aug 23 17:24:52 2017 -0300

    add EINA_VALUE_EMPTY, allow flushing empty values.
    
    EINA_VALUE_EMPTY is basically a zeroed Eina_Value, handy for declaring
    and returning.
    
    To cope with the rest of efl, free/del/flush on NULL shouldn't
    complain, so flusing an empty value should be quiet.
---
 src/lib/eina/eina_inline_value.x |  1 +
 src/lib/eina/eina_value.h        | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/src/lib/eina/eina_inline_value.x b/src/lib/eina/eina_inline_value.x
index 649e1de2a8..b8614c7ea9 100644
--- a/src/lib/eina/eina_inline_value.x
+++ b/src/lib/eina/eina_inline_value.x
@@ -136,6 +136,7 @@ eina_value_flush(Eina_Value *value)
    const Eina_Value_Type *type;
    void *mem;
 
+   if (!value || !value->type) return;
    EINA_VALUE_TYPE_CHECK_RETURN(value);
 
    type = value->type;
diff --git a/src/lib/eina/eina_value.h b/src/lib/eina/eina_value.h
index d163b11d5b..756314cb85 100644
--- a/src/lib/eina/eina_value.h
+++ b/src/lib/eina/eina_value.h
@@ -305,6 +305,16 @@
 typedef struct _Eina_Value Eina_Value;
 
 /**
+ * @def EINA_VALUE_EMPTY
+ *
+ * This is simply a value with all memory zeroed. It may be used
+ * to safely initialize or return a value without a type.
+ *
+ * @since 1.21
+ */
+#define EINA_VALUE_EMPTY ((Eina_Value){ 0 })
+
+/**
  * @typedef Eina_Value_Type
  * Describes the data contained by the value.
  *

-- 


Reply via email to