replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / connectivity / common / inc / uarraylist.h
index a055a1b..cf1085b 100644 (file)
@@ -22,7 +22,7 @@
 #define U_ARRAYLIST_H_
 
 #include <stdint.h>
-#include "cacommon.h"
+#include <stdbool.h>
 
 #ifdef __cplusplus
 extern "C"
@@ -31,12 +31,16 @@ extern "C"
 
 /**
  * array list structure.
+ *
+ * @note
+ * Members should be treated as private and not accessed directly. Instead
+ * all access should be through the defined u_arraylist_*() functions.
  */
 typedef struct u_arraylist_t
 {
     void **data;
     uint32_t length;
-    uint32_t size;
+    uint32_t capacity;
 } u_arraylist_t;
 
 /**
@@ -50,10 +54,31 @@ u_arraylist_t *u_arraylist_create();
  * Arraylist elements are deleted. Calling function must take care of free
  * dynamic memory allocated before freeing the arraylist.
  * @param[in] list       u_arraylist pointer
- * @return ::CAResult_t.
- * ::CA_STATUS_OK if Success, ::CA_STATUS_INVALID_PARAM if pointer to list is NULL.
  */
-CAResult_t u_arraylist_free(u_arraylist_t **list);
+void u_arraylist_free(u_arraylist_t **list);
+
+/**
+ * Request that the list prepare room for the specified number of entries.
+ * If count is greater than the current internal storage size then an
+ * an attempt will be made to reallocate room for at least count items.
+ *
+ * In other cases there will be no effect.
+ *
+ * This call will not affect the length used and cannot be used to remove
+ * entries.
+ * @param list the list to operate on.
+ * @param count the size to attempt to reserve room for.
+ * @return true if success, false otherwise.
+ */
+bool u_arraylist_reserve(u_arraylist_t *list, size_t count);
+
+/**
+ * Request that the storage in the list be reduced to fit its current length.
+ *
+ * The request is non-binding, and may not affect the entries in the list.
+ * @param list the list to operate on.
+ */
+void u_arraylist_shrink_to_fit(u_arraylist_t *list);
 
 /**
  * Returns the data of the index from the array list.
@@ -64,13 +89,21 @@ CAResult_t u_arraylist_free(u_arraylist_t **list);
 void *u_arraylist_get(const u_arraylist_t *list, uint32_t index);
 
 /**
+ * Returns the index of the data from the array list.
+ * @param[in] list         pointer of array list.
+ * @param[in] data         pointer of data.
+ * @param[out]index        index of array list.
+ * @return true if success, false otherwise.
+ */
+bool u_arraylist_get_index(const u_arraylist_t *list, const void *data,  uint32_t *index);
+
+/**
  * Add data in the array list.
  * @param[in] list        pointer of array list.
  * @param[in] data        pointer of data.
- * @return CAResult_t.
- * ::CA_STATUS_OK if Success, ::CA_MEMORY_ALLOC_FAILED if memory allocation fails.
+ * @return true if success, false otherwise.
  */
-CAResult_t u_arraylist_add(u_arraylist_t *list, void *data);
+bool u_arraylist_add(u_arraylist_t *list, void *data);
 
 /**
  * Remove the data of the index from the array list.