mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
astobj2: Eliminate usage of legacy ao2_container_alloc routine.
Replace usage of ao2_container_alloc with ao2_container_alloc_hash or ao2_container_alloc_list. ao2_container_alloc is now restricted to modules only and is being removed from Asterisk 17. Change-Id: I0907d78bc66efc775672df37c8faad00f2f6c088
This commit is contained in:
@@ -714,9 +714,9 @@ AST_TEST_DEFINE(astobj2_test_2)
|
||||
break;
|
||||
}
|
||||
|
||||
c = ao2_container_alloc(1, NULL, test_cmp_cb);
|
||||
c = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_MUTEX, 0, NULL, test_cmp_cb);
|
||||
if (!c) {
|
||||
ast_test_status_update(test, "ao2_container_alloc failed.\n");
|
||||
ast_test_status_update(test, "ao2_container_alloc_list failed.\n");
|
||||
res = AST_TEST_FAIL;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@@ -268,8 +268,8 @@ AST_TEST_DEFINE(hash_test)
|
||||
data.preload = MAX_HASH_ENTRIES / 2;
|
||||
data.max_grow = MAX_HASH_ENTRIES - data.preload;
|
||||
data.deadline = ast_tvadd(ast_tvnow(), ast_tv(MAX_TEST_SECONDS, 0));
|
||||
data.to_be_thrashed = ao2_container_alloc(HASH_BUCKETS, hash_string,
|
||||
compare_strings);
|
||||
data.to_be_thrashed = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0,
|
||||
HASH_BUCKETS, hash_string, NULL, compare_strings);
|
||||
|
||||
if (data.to_be_thrashed == NULL) {
|
||||
ast_test_status_update(test, "Allocation failed\n");
|
||||
|
@@ -1839,8 +1839,8 @@ static int test_cel_init_cb(struct ast_test_info *info, struct ast_test *test)
|
||||
ast_cel_set_config(cel_test_config);
|
||||
|
||||
/* init CEL event storage (degenerate hash table becomes a linked list) */
|
||||
cel_received_events = ao2_container_alloc(1, NULL, NULL);
|
||||
cel_expected_events = ao2_container_alloc(1, NULL, NULL);
|
||||
cel_received_events = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_MUTEX, 0, NULL, NULL);
|
||||
cel_expected_events = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_MUTEX, 0, NULL, NULL);
|
||||
|
||||
/* start the CEL event callback */
|
||||
if (ast_cel_backend_register(TEST_BACKEND_NAME, test_sub)) {
|
||||
|
@@ -1366,12 +1366,6 @@ struct test_config {
|
||||
struct ao2_container *items;
|
||||
};
|
||||
|
||||
static int test_item_hash(const void *obj, const int flags)
|
||||
{
|
||||
const struct test_item *item = obj;
|
||||
const char *name = (flags & OBJ_KEY) ? obj : item->name;
|
||||
return ast_str_case_hash(name);
|
||||
}
|
||||
static int test_item_cmp(void *obj, void *arg, int flags)
|
||||
{
|
||||
struct test_item *one = obj, *two = arg;
|
||||
@@ -1424,7 +1418,8 @@ static void *test_config_alloc(void)
|
||||
if (!(cfg->global_defaults = test_item_alloc("global_defaults"))) {
|
||||
goto error;
|
||||
}
|
||||
if (!(cfg->items = ao2_container_alloc(1, test_item_hash, test_item_cmp))) {
|
||||
cfg->items = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_MUTEX, 0, NULL, test_item_cmp);
|
||||
if (!cfg->items) {
|
||||
goto error;
|
||||
}
|
||||
return cfg;
|
||||
|
@@ -199,8 +199,8 @@ AST_TEST_DEFINE(cleanup_order)
|
||||
enum ast_test_result_state res = AST_TEST_PASS;
|
||||
struct ao2_iterator iter;
|
||||
struct test_struct *object_iter;
|
||||
RAII_VAR(struct ao2_container*, container, ao2_container_alloc(13, NULL, NULL), ao2_cleanup);
|
||||
RAII_VAR(struct test_struct *, object, ao2_alloc(sizeof(*object), NULL), ao2_cleanup);
|
||||
RAII_VAR(struct ao2_container*, container, NULL, ao2_cleanup);
|
||||
RAII_VAR(struct test_struct *, object, NULL, ao2_cleanup);
|
||||
|
||||
switch(cmd) {
|
||||
case TEST_INIT:
|
||||
@@ -216,6 +216,8 @@ AST_TEST_DEFINE(cleanup_order)
|
||||
}
|
||||
current_test = test;
|
||||
|
||||
container = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0, 13, NULL, NULL, NULL);
|
||||
object = ao2_alloc(sizeof(*object), NULL);
|
||||
if (!object || !container) {
|
||||
/* Allocation failure. We can't even pretend to do this test properly */
|
||||
return AST_TEST_FAIL;
|
||||
|
Reference in New Issue
Block a user