X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=resource%2Fcsdk%2Fconnectivity%2Fcommon%2Finc%2Fuarraylist.h;h=31a70f6ca6c4601647de8594e732805d10368c4a;hb=17c68b2fd1e74586f85e552eeab4e32dc121f8a0;hp=7fa6200ac9ad6c4090469aed6f6df34c461a4c6a;hpb=8c01dff2c5bc5496f7dc1632c498943ec6ecb015;p=platform%2Fupstream%2Fiotivity.git diff --git a/resource/csdk/connectivity/common/inc/uarraylist.h b/resource/csdk/connectivity/common/inc/uarraylist.h index 7fa6200..31a70f6 100644 --- a/resource/csdk/connectivity/common/inc/uarraylist.h +++ b/resource/csdk/connectivity/common/inc/uarraylist.h @@ -1,4 +1,4 @@ -/****************************************************************** +/* **************************************************************** * * Copyright 2014 Samsung Electronics All Rights Reserved. * @@ -22,7 +22,7 @@ #define U_ARRAYLIST_H_ #include -#include "cacommon.h" +#include #ifdef __cplusplus extern "C" @@ -30,85 +30,97 @@ extern "C" #endif /** - * @struct u_arraylist_t - * @brief array list structure + * 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; /** - * @brief API to creates array list and initializes the elements. - * @return u_arraylist_t if Success, NULL otherwise + * API to creates array list and initializes the elements. + * @return u_arraylist_t if Success, NULL otherwise. */ u_arraylist_t *u_arraylist_create(); /** - * @brief Resets and deletes the array list + * Resets and deletes the array list. * Arraylist elements are deleted. Calling function must take care of free - * dynamic memory allocated before freeing the arraylist - * @param list- u_arraylist pointer - * @return CAResult_t - * CA_STATUS_OK if Success, CA_STATUS_INVALID_PARAM if pointer to list is NULL + * dynamic memory allocated before freeing the arraylist. + * @param[in] list u_arraylist pointer + */ +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. + */ +void 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. */ -CAResult_t u_arraylist_free(u_arraylist_t **list); +void u_arraylist_shrink_to_fit(u_arraylist_t *list); /** - * @brief Returns the data of the index from the array list - * @param list - * [IN] pointer of array list - * @param index - * [IN] index of array list - * @return void pointer of data if success or NULL pointer otherwise + * Returns the data of the index from the array list. + * @param[in] list pointer of array list. + * @param[in] index index of array list. + * @return void pointer of data if success or NULL pointer otherwise. */ void *u_arraylist_get(const u_arraylist_t *list, uint32_t index); /** - * @brief Add data in the array list - * @param list - * [IN] pointer of array list - * @param data - * [IN] pointer of data - * @return CAResult_t - * CA_STATUS_OK if Success, CA_MEMORY_ALLOC_FAILED if memory allocation fails + * Add data in the array list. + * @param[in] list pointer of array list. + * @param[in] data pointer of data. + * @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); /** - * @brief Remove the data of the index from the array list - * @param list - * [IN] pointer of array list - * @param index - * [IN] index of array list - * @return void pointer of the data if success or NULL pointer otherwise + * Remove the data of the index from the array list. + * @param[in] list pointer of array list. + * @param[in] index index of array list. + * @return void pointer of the data if success or NULL pointer otherwise. */ void *u_arraylist_remove(u_arraylist_t *list, uint32_t index); /** - * @brief Returns the length of the array list - * @param list - * [IN] pointer of array list - * @return length of the array list + * Returns the length of the array list. + * @param[in] list pointer of array list. + * @return length of the array list. */ uint32_t u_arraylist_length(const u_arraylist_t *list); /** - * @brief Returns whether the data exists or not - * @param list - * [IN] pointer of array list - * @param data - * [IN] pointer of data - * @return true if exists, false otherwise + * Returns whether the data exists or not. + * @param[in] list pointer of array list. + * @param[in] data pointer of data. + * @return true if exists, false otherwise. */ bool u_arraylist_contains(const u_arraylist_t *list,const void *data); /** - * @brief Destroys array list and elements (assuming elements are shallow) - * @param list - * [IN] pointer of array list + * Destroys array list and elements (assuming elements are shallow). + * @param[in] list pointer of array list. */ void u_arraylist_destroy(u_arraylist_t *list);