37 #define DATASTORE_BUCKETS 53
41 const char *file,
int line,
const char *
function)
50 datastore = __ast_calloc(1,
sizeof(*datastore), file, line,
function);
58 if (!ast_strlen_zero(uid) && !(datastore->
uid =
ast_strdup(uid))) {
79 datastore->
data = NULL;
83 if (datastore->
uid != NULL) {
84 ast_free((
void *) datastore->
uid);
85 datastore->
uid = NULL;
107 ast_assert(datastore != NULL);
108 ast_assert(datastore->
info != NULL);
109 ast_assert(!ast_strlen_zero(datastore->
uid));
111 if (!
ao2_link(datastores, datastore)) {
128 static void datastore_destroy(
void *obj)
135 datastore->
data = NULL;
138 ast_free((
void *) datastore->
uid);
139 datastore->
uid = NULL;
145 char uuid_buf[AST_UUID_STR_LEN];
146 const char *uid_ptr =
uid;
152 datastore = ao2_alloc(
sizeof(*datastore), datastore_destroy);
158 if (ast_strlen_zero(uid)) {
164 if (!datastore->
uid) {
Asterisk main include file. File version handling, generic pbx functions.
AO2_STRING_FIELD_HASH_FN(transport_monitor, key)
Hashing function for struct transport_monitor.
int ast_datastores_add(struct ao2_container *datastores, struct ast_datastore *datastore)
Add a data store to a container.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
The arg parameter is a search key, but is not an object.
struct ast_datastore * ast_datastores_find(struct ao2_container *datastores, const char *name)
Find a data store in a container.
Universally unique identifier support.
Structure for a data store type.
AO2_STRING_FIELD_CMP_FN(transport_monitor, key)
Comparison function for struct transport_monitor.
#define ast_strdup(str)
A wrapper for strdup()
Structure for a data store object.
Asterisk datastore objects.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
const struct ast_datastore_info * info
void(* destroy)(void *data)
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
#define ast_module_ref(mod)
Hold a reference to the module.
#define DATASTORE_BUCKETS
Number of buckets for datastore container.
char * ast_uuid_generate_str(char *buf, size_t size)
Generate a UUID string.
Prototypes for public functions only of internal interest,.
#define ast_module_unref(mod)
Release a reference to the module.
struct ao2_container * ast_datastores_alloc(void)
Allocate a specialized data stores container.
void ast_datastores_remove(struct ao2_container *datastores, const char *name)
Remove a data store from a container.
struct ast_datastore * __ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid, struct ast_module *mod, const char *file, int line, const char *function)
Create a data store object.
struct ast_datastore * ast_datastores_alloc_datastore(const struct ast_datastore_info *info, const char *uid)
Allocate a datastore for use with the datastores container.
Asterisk module definitions.
#define ao2_link(container, obj)
Add an object to a container.