Esempio n. 1
0
/*! \brief Allocate an \ref ast_ari_conf for config parsing */
static void *conf_alloc(void)
{
	struct ast_ari_conf *cfg;

	cfg = ao2_alloc_options(sizeof(*cfg), conf_destructor,
		AO2_ALLOC_OPT_LOCK_NOLOCK);
	if (!cfg) {
		return NULL;
	}

	cfg->general = ao2_alloc_options(sizeof(*cfg->general), conf_general_dtor,
		AO2_ALLOC_OPT_LOCK_NOLOCK);

	cfg->users = ao2_container_alloc_rbtree(AO2_ALLOC_OPT_LOCK_NOLOCK,
		AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, user_sort_cmp, NULL);

	if (!cfg->users
		|| !cfg->general
		|| ast_string_field_init(cfg->general, 64)
		|| aco_set_defaults(&general_option, "general", cfg->general)) {
		ao2_ref(cfg, -1);
		return NULL;
	}

	return cfg;
}
Esempio n. 2
0
/*! \brief Allocate an \ref ast_ari_conf for config parsing */
static void *conf_alloc(void)
{
	RAII_VAR(struct ast_ari_conf *, cfg, NULL, ao2_cleanup);

	cfg = ao2_alloc_options(sizeof(*cfg), conf_destructor,
		AO2_ALLOC_OPT_LOCK_NOLOCK);
	if (!cfg) {
		return NULL;
	}

	cfg->general = ao2_alloc_options(sizeof(*cfg->general), NULL,
		AO2_ALLOC_OPT_LOCK_NOLOCK);
	if (!cfg->general) {
		return NULL;
	}
	aco_set_defaults(&general_option, "general", cfg->general);

	if (ast_string_field_init(cfg->general, 64)) {
		return NULL;
	}

	cfg->users = ao2_container_alloc_rbtree(AO2_ALLOC_OPT_LOCK_NOLOCK,
		AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, user_sort_cmp, NULL);

	ao2_ref(cfg, +1);
	return cfg;
}