[asterisk-commits] mjordan: branch group/bridge_construction r385395 - in /team/group/bridge_con...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Apr 11 20:43:45 CDT 2013
Author: mjordan
Date: Thu Apr 11 20:43:42 2013
New Revision: 385395
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385395
Log:
For now, move the string ao2 container into astobj2
The utils folder won't compile with ao2 objects in strings.c, as it has a silly
build system.
Modified:
team/group/bridge_construction/include/asterisk/astobj2.h
team/group/bridge_construction/include/asterisk/strings.h
team/group/bridge_construction/main/astobj2.c
team/group/bridge_construction/main/strings.c
Modified: team/group/bridge_construction/include/asterisk/astobj2.h
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/include/asterisk/astobj2.h?view=diff&rev=385395&r1=385394&r2=385395
==============================================================================
--- team/group/bridge_construction/include/asterisk/astobj2.h (original)
+++ team/group/bridge_construction/include/asterisk/astobj2.h Thu Apr 11 20:43:42 2013
@@ -1883,4 +1883,37 @@
#define ao2_cleanup(obj) __ao2_cleanup(obj)
#endif
void ao2_iterator_cleanup(struct ao2_iterator *iter);
+
+
+/* XXX TODO BUGBUG and all the other things...
+ * These functions should eventually be moved elsewhere, but the utils folder
+ * won't compile with them in strings.h
+ */
+
+/*!
+ * \since 12
+ * \brief Allocates a hash container for bare strings
+ *
+ * \param buckets The number of buckets to use for the hash container
+ *
+ * \retval AO2 container for strings
+ * \retval NULL if allocation failed
+ */
+struct ao2_container *ast_str_container_alloc(int buckets);
+
+/*!
+ * \since 12
+ * \brief Adds a string to a string container allocated by ast_str_container_alloc
+ *
+ * \param str_container The container to which to add a string
+ * \param add The string to add to the container
+ *
+ * \retval zero on success
+ * \retval non-zero if the operation failed
+ */
+int ast_str_container_add(struct ao2_container *str_container, const char *add);
+
+
+
+
#endif /* _ASTERISK_ASTOBJ2_H */
Modified: team/group/bridge_construction/include/asterisk/strings.h
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/include/asterisk/strings.h?view=diff&rev=385395&r1=385394&r2=385395
==============================================================================
--- team/group/bridge_construction/include/asterisk/strings.h (original)
+++ team/group/bridge_construction/include/asterisk/strings.h Thu Apr 11 20:43:42 2013
@@ -1014,26 +1014,5 @@
return abs(hash);
}
-/*!
- * \since 12
- * \brief Allocates a hash container for bare strings
- *
- * \param buckets The number of buckets to use for the hash container
- *
- * \retval AO2 container for strings
- * \retval NULL if allocation failed
- */
-struct ao2_container *ast_str_container_alloc(int buckets);
-
-/*!
- * \since 12
- * \brief Adds a string to a string container allocated by ast_str_container_alloc
- *
- * \param str_container The container to which to add a string
- * \param add The string to add to the container
- *
- * \retval zero on success
- * \retval non-zero if the operation failed
- */
-int ast_str_container_add(struct ao2_container *str_container, const char *add);
+
#endif /* _ASTERISK_STRINGS_H */
Modified: team/group/bridge_construction/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/main/astobj2.c?view=diff&rev=385395&r1=385394&r2=385395
==============================================================================
--- team/group/bridge_construction/main/astobj2.c (original)
+++ team/group/bridge_construction/main/astobj2.c Thu Apr 11 20:43:42 2013
@@ -5779,3 +5779,36 @@
return 0;
}
+
+/* XXX TODO BUGBUG and all the other things...
+ * These functions should eventually be moved elsewhere, but the utils folder
+ * won't compile with them in strings.h
+ */
+static int str_hash(const void *obj, const int flags)
+{
+ return ast_str_hash(obj);
+}
+
+static int str_cmp(void *lhs, void *rhs, int flags)
+{
+ return strcmp(lhs, rhs) ? 0 : CMP_MATCH;
+}
+
+struct ao2_container *ast_str_container_alloc(int buckets)
+{
+ return ao2_container_alloc(buckets, str_hash, str_cmp);
+}
+
+int ast_str_container_add(struct ao2_container *str_container, const char *add)
+{
+ RAII_VAR(char *, ao2_add, ao2_alloc(strlen(add) + 1, NULL), ao2_cleanup);
+
+ if (!ao2_add) {
+ return -1;
+ }
+
+ /* safe strcpy */
+ strcpy(ao2_add, add);
+ ao2_link(str_container, ao2_add);
+ return 0;
+}
Modified: team/group/bridge_construction/main/strings.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/main/strings.c?view=diff&rev=385395&r1=385394&r2=385395
==============================================================================
--- team/group/bridge_construction/main/strings.c (original)
+++ team/group/bridge_construction/main/strings.c Thu Apr 11 20:43:42 2013
@@ -160,31 +160,4 @@
return (*buf)->__AST_STR_STR;
}
-static int str_hash(const void *obj, const int flags)
-{
- return ast_str_hash(obj);
-}
-static int str_cmp(void *lhs, void *rhs, int flags)
-{
- return strcmp(lhs, rhs) ? 0 : CMP_MATCH;
-}
-
-struct ao2_container *ast_str_container_alloc(int buckets)
-{
- return ao2_container_alloc(buckets, str_hash, str_cmp);
-}
-
-int ast_str_container_add(struct ao2_container *str_container, const char *add)
-{
- RAII_VAR(char *, ao2_add, ao2_alloc(strlen(add) + 1, NULL), ao2_cleanup);
-
- if (!ao2_add) {
- return -1;
- }
-
- /* safe strcpy */
- strcpy(ao2_add, add);
- ao2_link(str_container, ao2_add);
- return 0;
-}
More information about the asterisk-commits
mailing list