Move ast_str_container_alloc and friends

This moves ast_str_container_alloc, ast_str_container_add,
ast_str_container_remove, and related private functions into
strings.c/h since they really don't belong in astobj2.c/h.

As a result of this move, utils also had to be updated.

Review: https://reviewboard.asterisk.org/r/2719/
(closes issue ASTERISK-22041)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396105 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kinsey Moore
2013-08-02 14:08:34 +00:00
parent f8622e7c5c
commit 41d6be2432
6 changed files with 87 additions and 88 deletions

View File

@@ -5797,40 +5797,3 @@ int astobj2_init(void)
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_options(enum ao2_container_opts opts, int buckets)
{
return ao2_container_alloc_options(opts, 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;
}
void ast_str_container_remove(struct ao2_container *str_container, const char *remove)
{
ao2_find(str_container, remove, OBJ_KEY | OBJ_NODATA | OBJ_UNLINK);
}