Update datastores documentation. (issue #9801 reported by mnicholson)

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@66398 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Joshua Colp
2007-05-29 15:43:16 +00:00
parent bab6473879
commit 732418a95a

View File

@@ -22,9 +22,8 @@ This is a needed structure that contains information about a datastore, it's use
1. Use ast_channel_datastore_alloc function to return a pre-allocated structure 1. Use ast_channel_datastore_alloc function to return a pre-allocated structure
Ex: datastore = ast_channel_datastore_alloc(&example_datastore, "uid"); Ex: datastore = ast_channel_datastore_alloc(&example_datastore, "uid");
This function takes two arguments: (datastore info structure, uid) This function takes two arguments: (datastore info structure, uid)
2. Attach data and destroy callback to pre-allocated structure. 2. Attach data to pre-allocated structure.
Ex: datastore->data = mysillydata; Ex: datastore->data = mysillydata;
datastore->destroy = callback_destroy;
3. Add datastore to the channel 3. Add datastore to the channel
Ex: ast_channel_datastore_add(chan, datastore); Ex: ast_channel_datastore_add(chan, datastore);
This function takes two arguments: (pointer to channel, pointer to data store) This function takes two arguments: (pointer to channel, pointer to data store)
@@ -33,13 +32,12 @@ Full Example:
void callback_destroy(void *data) void callback_destroy(void *data)
{ {
free(data); ast_free(data);
} }
struct ast_datastore *datastore = NULL; struct ast_datastore *datastore = NULL;
datastore = ast_channel_datastore_alloc(&example_datastore, NULL); datastore = ast_channel_datastore_alloc(&example_datastore, NULL);
datastore->data = mysillydata; datastore->data = mysillydata;
datastore->destroy = callback_destroy;
ast_channel_datastore_add(chan, datastore); ast_channel_datastore_add(chan, datastore);
NOTE: Because you're passing a pointer to a function in your module, you'll want to include NOTE: Because you're passing a pointer to a function in your module, you'll want to include
@@ -53,11 +51,8 @@ this in your use count. When allocated increment, when destroyed decrement.
2. Remove the data store from the channel 2. Remove the data store from the channel
Ex: ast_channel_datastore_remove(chan, datastore); Ex: ast_channel_datastore_remove(chan, datastore);
This function takes two arguments: (pointer to channel, pointer to data store) This function takes two arguments: (pointer to channel, pointer to data store)
3. If we want to now, free the memory or do stuff to the data on the data store 3. If we want to now do stuff to the data on the data store
If we do then we will want to unset the data and callback 4. Free the data store (this will call the destroy call back)
Ex: datastore->data = NULL;
datastore->destroy = NULL;
4. Free the data store
Ex: ast_channel_datastore_free(datastore); Ex: ast_channel_datastore_free(datastore);
This function takes one argument: (pointer to data store) This function takes one argument: (pointer to data store)