datastore.c File Reference

Asterisk datastore objects. More...

#include "asterisk.h"
#include "asterisk/_private.h"
#include "asterisk/datastore.h"
#include "asterisk/utils.h"

Include dependency graph for datastore.c:

Go to the source code of this file.

Functions

struct ast_datastore__ast_datastore_alloc (const struct ast_datastore_info *info, const char *uid, const char *file, int line, const char *function)
 Create a data store object.
int ast_datastore_free (struct ast_datastore *datastore)
 Free a data store object.


Detailed Description

Asterisk datastore objects.

Definition in file datastore.c.


Function Documentation

struct ast_datastore* __ast_datastore_alloc ( const struct ast_datastore_info info,
const char *  uid,
const char *  file,
int  line,
const char *  function 
) [read]

Create a data store object.

Parameters:
[in] info information describing the data store object
[in] uid unique identifer
file,line,function 
Version:
1.6.1 moved here and renamed from ast_channel_datastore_alloc

Definition at line 35 of file datastore.c.

References __ast_calloc(), ast_calloc, ast_free, ast_strdup, ast_strlen_zero, ast_datastore::info, NULL, and ast_datastore::uid.

00037 {
00038    struct ast_datastore *datastore = NULL;
00039 
00040    /* Make sure we at least have type so we can identify this */
00041    if (!info) {
00042       return NULL;
00043    }
00044 
00045 #if defined(__AST_DEBUG_MALLOC)
00046    if (!(datastore = __ast_calloc(1, sizeof(*datastore), file, line, function))) {
00047       return NULL;
00048    }
00049 #else
00050    if (!(datastore = ast_calloc(1, sizeof(*datastore)))) {
00051       return NULL;
00052    }
00053 #endif
00054 
00055    datastore->info = info;
00056 
00057    if (!ast_strlen_zero(uid) && !(datastore->uid = ast_strdup(uid))) {
00058       ast_free(datastore);
00059       datastore = NULL;
00060    }
00061 
00062    return datastore;
00063 }

int ast_datastore_free ( struct ast_datastore datastore  ) 

Free a data store object.

Parameters:
[in] datastore datastore to free
Version:
1.6.1 moved here and renamed from ast_channel_datastore_free

Definition at line 65 of file datastore.c.

References ast_free, ast_datastore::data, ast_datastore_info::destroy, ast_datastore::info, NULL, and ast_datastore::uid.

Referenced by __after_bridge_set_goto(), acf_curlopt_write(), acf_fetch(), acf_iaxvar_write(), acf_odbc_read(), add_features_datastore(), add_to_agi(), adjust_frame_for_plc(), after_bridge_cb_setup(), apply_plc(), ast_bridge_discard_after_goto(), ast_bridge_setup_after_goto(), ast_cel_fabricate_channel_from_event(), ast_channel_datastore_free(), ast_channel_destructor(), ast_channel_unsuppress(), ast_do_pickup(), ast_dummy_channel_destructor(), ast_iax2_new(), ast_jb_create_framehook(), ast_setup_cc_recall_datastore(), audiohook_volume_get(), authenticate_reply(), bridge_features_ds_set_full(), cc_interfaces_datastore_init(), chan_cleanup(), channel_feature_hooks_set_full(), clear_dialed_interfaces(), create_parked_subscription_full(), dial_exec_full(), dial_masquerade_datastore_add(), dial_masquerade_fixup(), disable_jack_hook(), enable_jack_hook(), exec_odbcfinish(), find_transaction(), fixup_callback(), frame_trace_helper(), func_confbridge_helper(), get_lock(), gosub_exec(), init_hook(), lua_get_state(), msg_datastore_find_or_create(), pitchshift_helper(), raise_exception(), remove_dial_masquerade(), remove_masquerade_store(), remove_stasis_end_published(), remove_talk_detect(), session_destructor(), set_dial_masquerade(), set_talk_detect(), setup_bridge_roles_datastore(), setup_park_common_datastore(), shared_write(), socket_process_helper(), speech_datastore_destroy(), speex_write(), srv_query_read(), stop_mixmonitor_full(), try_calling(), volume_write(), wipe_park_common_datastore(), and wipe_subscription_datastore().

00066 {
00067    int res = 0;
00068 
00069    /* Using the destroy function (if present) destroy the data */
00070    if (datastore->info->destroy != NULL && datastore->data != NULL) {
00071       datastore->info->destroy(datastore->data);
00072       datastore->data = NULL;
00073    }
00074 
00075    /* Free allocated UID memory */
00076    if (datastore->uid != NULL) {
00077       ast_free((void *) datastore->uid);
00078       datastore->uid = NULL;
00079    }
00080 
00081    /* Finally free memory used by ourselves */
00082    ast_free(datastore);
00083 
00084    return res;
00085 }


Generated on Thu Apr 16 06:30:35 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6