#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_strdup, 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 datastore->uid = ast_strdup(uid); 00054 00055 return datastore; 00056 }
struct ast_datastore * ast_datastore_alloc | ( | const struct ast_datastore_info * | info, | |
const char * | uid | |||
) |
Definition at line 91 of file datastore.c.
References __ast_datastore_alloc(), and ast_datastore::info.
00092 { 00093 return __ast_datastore_alloc(info, uid, __FILE__, __LINE__, __FUNCTION__); 00094 }
int ast_datastore_free | ( | struct ast_datastore * | datastore | ) |
Free a data store object.
[in] | datastore | datastore to free |
Definition at line 58 of file datastore.c.
References ast_free, ast_datastore::data, ast_datastore_info::destroy, ast_datastore::info, and ast_datastore::uid.
Referenced by acf_fetch(), add_features_datastores(), add_to_agi(), ast_channel_datastore_free(), ast_channel_free(), ast_iax2_new(), audiohook_volume_get(), authenticate_reply(), chanspy_ds_free(), dial_exec_full(), disable_jack_hook(), exec_odbcfinish(), free_session(), get_lock(), gosub_exec(), lua_get_state(), pbx_builtin_raise_exception(), setup_inheritance_datastore(), shared_write(), socket_process(), speex_write(), stop_mixmonitor_exec(), try_calling(), and volume_write().
00059 { 00060 int res = 0; 00061 00062 /* Using the destroy function (if present) destroy the data */ 00063 if (datastore->info->destroy != NULL && datastore->data != NULL) { 00064 datastore->info->destroy(datastore->data); 00065 datastore->data = NULL; 00066 } 00067 00068 /* Free allocated UID memory */ 00069 if (datastore->uid != NULL) { 00070 ast_free((void *) datastore->uid); 00071 datastore->uid = NULL; 00072 } 00073 00074 /* Finally free memory used by ourselves */ 00075 ast_free(datastore); 00076 00077 return res; 00078 }