[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r301778 - in /team/dvossel/f...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jan 13 16:11:20 CST 2011
Author: dvossel
Date: Thu Jan 13 16:11:16 2011
New Revision: 301778
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=301778
Log:
improvments to ast_cap_copy
Modified:
team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h
team/dvossel/fixtheworld_phase1_step3/main/format_cap.c
Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h?view=diff&rev=301778&r1=301777&r2=301778
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h Thu Jan 13 16:11:16 2011
@@ -76,6 +76,12 @@
void ast_cap_append(struct ast_cap *dst, const struct ast_cap *src);
/*!
+ * \brief Copy all items in src to dst.
+ * \note any items in dst will be removed before copying
+ */
+void ast_cap_copy2(struct ast_cap *dst, const struct ast_cap *src);
+
+/*!
* \brief create a deep copy of an ast_cap structure
* \retval cap on success
* \retval NULL on failure
Modified: team/dvossel/fixtheworld_phase1_step3/main/format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/format_cap.c?view=diff&rev=301778&r1=301777&r2=301778
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/format_cap.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/format_cap.c Thu Jan 13 16:11:16 2011
@@ -148,22 +148,30 @@
ast_cap_iter_end(tmp_cap);
}
+
+static int copy_cb(void *obj, void *arg, int flag)
+{
+ struct ast_cap *result = (struct ast_cap *) arg;
+ struct ast_format *format = (struct ast_format *) obj;
+
+ ast_cap_add(result, format);
+ return 0;
+}
+
+void ast_cap_copy2(struct ast_cap *dst, const struct ast_cap *src)
+{
+ ast_cap_remove_all(dst);
+ ao2_callback(src->formats, 0, copy_cb, dst);
+}
+
struct ast_cap *ast_cap_copy(struct ast_cap *cap)
{
- struct ast_cap *copy = ast_cap_alloc();
- struct ast_format tmp_fmt;
-
- if (!copy) {
+ struct ast_cap *dst = ast_cap_alloc();
+ if (!dst) {
return NULL;
}
-
- ast_cap_iter_start(cap);
- while (!ast_cap_iter_next(cap, &tmp_fmt)) {
- ast_cap_add(copy, &tmp_fmt);
- }
- ast_cap_iter_end(cap);
-
- return copy;
+ ao2_callback(cap->formats, OBJ_NODATA, copy_cb, dst);
+ return dst;
}
int ast_cap_is_empty(const struct ast_cap *cap)
More information about the asterisk-commits
mailing list