#include "asterisk.h"
#include "asterisk/_private.h"
#include "asterisk/datastore.h"
#include "asterisk/utils.h"
Go to the source code of this file.
Functions | |
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. | |
ast_datastore * | ast_datastore_alloc (const struct ast_datastore_info *info, const char *uid) |
int | ast_datastore_free (struct ast_datastore *datastore) |
Free a data store object. |
Definition in file datastore.c.
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.
[in] | info | information describing the data store object |
[in] | uid | unique identifer |
Definition at line 31 of file datastore.c.
References __ast_calloc(), ast_calloc, ast_free, ast_strdup, ast_strlen_zero(), and ast_datastore::info.
Referenced by ast_datastore_alloc().
00033 { 00034 struct ast_datastore *datastore = NULL; 00035 00036 /* Make sure we at least have type so we can identify this */ 00037 if (!info) { 00038 return NULL; 00039 } 00040 00041 #if defined(__AST_DEBUG_MALLOC) 00042 if (!(datastore = __ast_calloc(1, sizeof(*datastore), file, line, function))) { 00043 return NULL; 00044 } 00045 #else 00046 if (!(datastore = ast_calloc(1, sizeof(*datastore)))) { 00047 return NULL; 00048 } 00049 #endif 00050 00051 datastore->info = info; 00052 00053 if (!ast_strlen_zero(uid) && !(datastore->uid = ast_strdup(uid))) { 00054 ast_free(datastore); 00055 datastore = NULL; 00056 } 00057 00058 return datastore; 00059 }
struct ast_datastore * ast_datastore_alloc | ( | const struct ast_datastore_info * | info, | |
const char * | uid | |||
) |
Definition at line 94 of file datastore.c.
References __ast_datastore_alloc(), and ast_datastore::info.
00095 { 00096 return __ast_datastore_alloc(info, uid, __FILE__, __LINE__, __FUNCTION__); 00097 }
int ast_datastore_free | ( | struct ast_datastore * | datastore | ) |
Free a data store object.
[in] | datastore | datastore to free |
Definition at line 61 of file datastore.c.
References ast_free, ast_datastore::data, ast_datastore_info::destroy, ast_datastore::info, and ast_datastore::uid.
Referenced by acf_curlopt_write(), acf_fetch(), add_features_datastores(), add_to_agi(), adjust_frame_for_plc(), apply_plc(), ast_channel_datastore_free(), ast_channel_destructor(), ast_channel_transfer_masquerade(), ast_do_masquerade(), ast_iax2_new(), ast_setup_cc_recall_datastore(), audiohook_volume_get(), authenticate_reply(), cc_interfaces_datastore_init(), dial_exec_full(), disable_jack_hook(), exec_odbcfinish(), find_transaction(), frame_trace_helper(), func_mute_write(), get_lock(), gosub_exec(), initialize_mutehook(), lua_get_state(), manager_mutestream(), pbx_builtin_raise_exception(), pitchshift_helper(), session_destructor(), setup_inheritance_datastore(), shared_write(), socket_process(), speex_write(), srv_query_read(), stop_mixmonitor_exec(), and volume_write().
00062 { 00063 int res = 0; 00064 00065 /* Using the destroy function (if present) destroy the data */ 00066 if (datastore->info->destroy != NULL && datastore->data != NULL) { 00067 datastore->info->destroy(datastore->data); 00068 datastore->data = NULL; 00069 } 00070 00071 /* Free allocated UID memory */ 00072 if (datastore->uid != NULL) { 00073 ast_free((void *) datastore->uid); 00074 datastore->uid = NULL; 00075 } 00076 00077 /* Finally free memory used by ourselves */ 00078 ast_free(datastore); 00079 00080 return res; 00081 }