Add a new internal function 70/211570/6
authorHwankyu Jhun <h.jhun@samsung.com>
Wed, 7 Aug 2019 08:57:31 +0000 (17:57 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Wed, 7 Aug 2019 10:39:12 +0000 (19:39 +0900)
Adds:
 - bundle_init_byte_array()

Change-Id: I7c190b53c69f528dbaf4fb97a95da143b300fe07
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/bundle_internal.h
src/bundle.c

index 8817b13..59499b2 100755 (executable)
@@ -506,6 +506,26 @@ API int bundle_from_json(const char *json, bundle **b);
  */
 API int bundle_compare(bundle *b1, bundle *b2);
 
+/**
+ * @brief Initializes a byte array type key-value pair into a bundle.
+ * @details To set the value of the byte array element, you should use bundle_set_byte_array_element().
+ *          This function is only for creating a buffer of the byte array.
+ * @since_tizen 5.5
+ *
+ * @param[in]   b               The bundle object
+ * @param[in]   key             The key
+ * @param[in]   len             The length of the array to be created
+ * @return      @c 0 on success,
+ *              otherwise a negative error value
+ * @retval #BUNDLE_ERROR_NONE Successful
+ * @retval #BUNDLE_ERROR_INVALID_PARAMETEr Invalid parameter
+ * @retval #BUNDLE_ERROR_KEY_EXISTS Key already exists
+ * @retval #BUNDLE_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ * @see bundle_set_byte_array_element()
+ */
+API int bundle_init_byte_array(bundle *b, const char *key, const unsigned int len);
+
 #ifdef __cplusplus
 }
 #endif
index 2afa47f..4513486 100644 (file)
@@ -1077,6 +1077,11 @@ int bundle_add_byte_array(bundle *b, const char *key, void **byte_array,
                        BUNDLE_TYPE_BYTE_ARRAY, len);
 }
 
+int bundle_init_byte_array(bundle *b, const char *key, const unsigned int len)
+{
+       return _bundle_add_kv(b, key, NULL, 0, BUNDLE_TYPE_BYTE_ARRAY, len);
+}
+
 int bundle_get_byte_array(bundle *b, const char *key, void ***byte_array,
                unsigned int *len, unsigned int **array_element_size)
 {