diff options
author | Dmitri Pal <dpal@redhat.com> | 2010-08-30 10:10:02 -0400 |
---|---|---|
committer | Dmitri Pal <dpal@redhat.com> | 2010-08-30 10:10:02 -0400 |
commit | 8ed793f9cdf2b7ccc90b3d2d6319a58f7843991a (patch) | |
tree | 1f789e235200adf8a05b8b9a85e62afcd81e0d0c /common/refarray/ref_array.h | |
parent | 1e137bae0f30ff57636a2c9489992050e5a9515a (diff) | |
download | sssd-master.tar.gz sssd-master.tar.xz sssd-master.zip |
Diffstat (limited to 'common/refarray/ref_array.h')
-rw-r--r-- | common/refarray/ref_array.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/common/refarray/ref_array.h b/common/refarray/ref_array.h index 4b4b2de..4012116 100644 --- a/common/refarray/ref_array.h +++ b/common/refarray/ref_array.h @@ -83,11 +83,34 @@ typedef enum * * Callback that can be provided by a caller * to free data when the storage is actually destroyed. + * + * @param[in] elem Pointer to the array element. + * @param[in] type Type of the operation performed. + * @param[in] data Application data that can be used + * inside the callback. + * No return value. */ typedef void (*ref_array_fn)(void *elem, ref_array_del_enum type, void *data); +/** + * @brief Copy callback + * + * Callback that can be provided by a caller + * to copy elements of the array. + * + * @param[in] elem Pointer to the array element. + * @param[out] new_elem Pointer to pointer to the new element. + * + * @return 0 - Success. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + * + * Callback can return other errors and the implementor's discretion. + */ +typedef int (*ref_array_copy_cb)(void *elem, + void *new_elem); /** * @brief Create referenced array @@ -313,6 +336,27 @@ int ref_array_swap(struct ref_array *ra, */ void ref_array_reset(struct ref_array *ra); + +/** + * @brief Copy array + * + * Function copies all contents calling a provided + * callback for every entry of the array. + * + * + * @param[in] ra Existing array object to copy. + * @param[in] copy_cb Copy callback. + * @param[out] copy_ra Newly allocated copy. + * + * @return 0 - Success. + * @return ENOMEM - No memory. + * @return EINVAL - Invalid argument. + */ +int ref_array_copy(struct ref_array *ra, + ref_array_copy_cb copy_cb, + struct ref_array **copy_ra); + + /** * @} */ |