Wed Oct 28 11:52:15 2009

Asterisk developer's documentation


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.
struct ast_datastoreast_datastore_alloc (const struct ast_datastore_info *info, const char *uid)
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
Version:
1.6.1 moved here and renamed from ast_channel_datastore_alloc

Definition at line 31 of file datastore.c.

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

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 
) [read]

Definition at line 91 of file datastore.c.

References __ast_datastore_alloc().

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.

Parameters:
[in] datastore datastore to free
Version:
1.6.1 moved here and renamed from ast_channel_datastore_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(), 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 }


Generated on Wed Oct 28 11:52:16 2009 for Asterisk - the Open Source PBX by  doxygen 1.5.6