Sun Oct 16 2011 08:42:44

Asterisk developer's documentation


datastore.h File Reference

Asterisk datastore objects. More...

Include dependency graph for datastore.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_datastore
 Structure for a data store object. More...
struct  ast_datastore_info
 Structure for a data store type. More...

Defines

#define ast_datastore_alloc(info, uid)   __ast_datastore_alloc(info, uid, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Functions

struct ast_datastore
*attribute_malloc 
__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.h.


Define Documentation

#define ast_datastore_alloc (   info,
  uid 
)    __ast_datastore_alloc(info, uid, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Definition at line 71 of file datastore.h.


Function Documentation

struct ast_datastore* attribute_malloc __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]infoinformation describing the data store object
[in]uidunique 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_datastore::info, ast_strlen_zero(), ast_datastore::uid, ast_strdup, and ast_free.

Referenced by ast_datastore_alloc().

{
   struct ast_datastore *datastore = NULL;

   /* Make sure we at least have type so we can identify this */
   if (!info) {
      return NULL;
   }

#if defined(__AST_DEBUG_MALLOC)
   if (!(datastore = __ast_calloc(1, sizeof(*datastore), file, line, function))) {
      return NULL;
   }
#else
   if (!(datastore = ast_calloc(1, sizeof(*datastore)))) {
      return NULL;
   }
#endif

   datastore->info = info;

   if (!ast_strlen_zero(uid) && !(datastore->uid = ast_strdup(uid))) {
      ast_free(datastore);
      datastore = NULL;
   }

   return datastore;
}
int ast_datastore_free ( struct ast_datastore datastore)

Free a data store object.

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

Definition at line 61 of file datastore.c.

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

Referenced by dial_exec_full(), disable_jack_hook(), stop_mixmonitor_exec(), try_calling(), gosub_exec(), audiohook_volume_get(), cc_interfaces_datastore_init(), ast_setup_cc_recall_datastore(), ast_iax2_new(), authenticate_reply(), socket_process(), ast_channel_destructor(), ast_channel_datastore_free(), adjust_frame_for_plc(), apply_plc(), ast_channel_transfer_masquerade(), ast_do_masquerade(), add_features_datastores(), clear_dialed_interfaces(), ast_do_pickup(), setup_inheritance_datastore(), acf_curlopt_write(), frame_trace_helper(), shared_write(), get_lock(), acf_fetch(), exec_odbcfinish(), pitchshift_helper(), speex_write(), srv_query_read(), volume_write(), session_destructor(), raise_exception(), lua_get_state(), add_to_agi(), initialize_mutehook(), func_mute_write(), manager_mutestream(), and find_transaction().

{
   int res = 0;

   /* Using the destroy function (if present) destroy the data */
   if (datastore->info->destroy != NULL && datastore->data != NULL) {
      datastore->info->destroy(datastore->data);
      datastore->data = NULL;
   }

   /* Free allocated UID memory */
   if (datastore->uid != NULL) {
      ast_free((void *) datastore->uid);
      datastore->uid = NULL;
   }

   /* Finally free memory used by ourselves */
   ast_free(datastore);

   return res;
}