mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-25 07:01:09 +00:00
Remove the typedefs on ao2_container and ao2_iterator. This is simply because
we don't typedef objects anywhere else in Asterisk, so we might as well make this follow the same convention. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@81448 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -645,10 +645,10 @@ static struct ast_iax2_queue {
|
|||||||
#define MAX_PEER_BUCKETS 1
|
#define MAX_PEER_BUCKETS 1
|
||||||
/* #define MAX_PEER_BUCKETS 563 */
|
/* #define MAX_PEER_BUCKETS 563 */
|
||||||
#endif
|
#endif
|
||||||
static ao2_container *peers;
|
static struct ao2_container *peers;
|
||||||
|
|
||||||
#define MAX_USER_BUCKETS MAX_PEER_BUCKETS
|
#define MAX_USER_BUCKETS MAX_PEER_BUCKETS
|
||||||
static ao2_container *users;
|
static struct ao2_container *users;
|
||||||
|
|
||||||
static struct ast_firmware_list {
|
static struct ast_firmware_list {
|
||||||
struct iax_firmware *wares;
|
struct iax_firmware *wares;
|
||||||
@@ -1152,7 +1152,7 @@ static int iax2_getpeername(struct sockaddr_in sin, char *host, int len)
|
|||||||
{
|
{
|
||||||
struct iax2_peer *peer = NULL;
|
struct iax2_peer *peer = NULL;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
ao2_iterator i;
|
struct ao2_iterator i;
|
||||||
|
|
||||||
i = ao2_iterator_init(peers, 0);
|
i = ao2_iterator_init(peers, 0);
|
||||||
while ((peer = ao2_iterator_next(&i))) {
|
while ((peer = ao2_iterator_next(&i))) {
|
||||||
@@ -2283,7 +2283,7 @@ static char *complete_iax2_show_peer(const char *line, const char *word, int pos
|
|||||||
struct iax2_peer *peer;
|
struct iax2_peer *peer;
|
||||||
char *res = NULL;
|
char *res = NULL;
|
||||||
int wordlen = strlen(word);
|
int wordlen = strlen(word);
|
||||||
ao2_iterator i;
|
struct ao2_iterator i;
|
||||||
|
|
||||||
/* 0 - iax2; 1 - show; 2 - peer; 3 - <peername> */
|
/* 0 - iax2; 1 - show; 2 - peer; 3 - <peername> */
|
||||||
if (pos != 3)
|
if (pos != 3)
|
||||||
@@ -3489,7 +3489,7 @@ static int iax2_getpeertrunk(struct sockaddr_in sin)
|
|||||||
{
|
{
|
||||||
struct iax2_peer *peer;
|
struct iax2_peer *peer;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
ao2_iterator i;
|
struct ao2_iterator i;
|
||||||
|
|
||||||
i = ao2_iterator_init(peers, 0);
|
i = ao2_iterator_init(peers, 0);
|
||||||
while ((peer = ao2_iterator_next(&i))) {
|
while ((peer = ao2_iterator_next(&i))) {
|
||||||
@@ -4218,7 +4218,7 @@ static int iax2_show_users(int fd, int argc, char *argv[])
|
|||||||
struct iax2_user *user = NULL;
|
struct iax2_user *user = NULL;
|
||||||
char auth[90];
|
char auth[90];
|
||||||
char *pstr = "";
|
char *pstr = "";
|
||||||
ao2_iterator i;
|
struct ao2_iterator i;
|
||||||
|
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
case 5:
|
case 5:
|
||||||
@@ -4276,7 +4276,7 @@ static int __iax2_show_peers(int manager, int fd, struct mansession *s, int argc
|
|||||||
int online_peers = 0;
|
int online_peers = 0;
|
||||||
int offline_peers = 0;
|
int offline_peers = 0;
|
||||||
int unmonitored_peers = 0;
|
int unmonitored_peers = 0;
|
||||||
ao2_iterator i;
|
struct ao2_iterator i;
|
||||||
|
|
||||||
#define FORMAT2 "%-15.15s %-15.15s %s %-15.15s %-8s %s %-10s%s"
|
#define FORMAT2 "%-15.15s %-15.15s %s %-15.15s %-8s %s %-10s%s"
|
||||||
#define FORMAT "%-15.15s %-15.15s %s %-15.15s %-5d%s %s %-10s%s"
|
#define FORMAT "%-15.15s %-15.15s %s %-15.15s %-5d%s %s %-10s%s"
|
||||||
@@ -4841,7 +4841,7 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies
|
|||||||
int bestscore = 0;
|
int bestscore = 0;
|
||||||
int gotcapability = 0;
|
int gotcapability = 0;
|
||||||
struct ast_variable *v = NULL, *tmpvar = NULL;
|
struct ast_variable *v = NULL, *tmpvar = NULL;
|
||||||
ao2_iterator i;
|
struct ao2_iterator i;
|
||||||
|
|
||||||
if (!iaxs[callno])
|
if (!iaxs[callno])
|
||||||
return res;
|
return res;
|
||||||
@@ -5432,7 +5432,7 @@ static int authenticate_reply(struct chan_iax2_pvt *p, struct sockaddr_in *sin,
|
|||||||
/* Normal password authentication */
|
/* Normal password authentication */
|
||||||
res = authenticate(p->challenge, override, okey, authmethods, &ied, sin, &p->ecx, &p->dcx);
|
res = authenticate(p->challenge, override, okey, authmethods, &ied, sin, &p->ecx, &p->dcx);
|
||||||
} else {
|
} else {
|
||||||
ao2_iterator i = ao2_iterator_init(peers, 0);
|
struct ao2_iterator i = ao2_iterator_init(peers, 0);
|
||||||
while ((peer = ao2_iterator_next(&i))) {
|
while ((peer = ao2_iterator_next(&i))) {
|
||||||
if ((ast_strlen_zero(p->peer) || !strcmp(p->peer, peer->name))
|
if ((ast_strlen_zero(p->peer) || !strcmp(p->peer, peer->name))
|
||||||
/* No peer specified at our end, or this is the peer */
|
/* No peer specified at our end, or this is the peer */
|
||||||
@@ -9418,7 +9418,7 @@ static void delete_users(void)
|
|||||||
static void prune_users(void)
|
static void prune_users(void)
|
||||||
{
|
{
|
||||||
struct iax2_user *user;
|
struct iax2_user *user;
|
||||||
ao2_iterator i;
|
struct ao2_iterator i;
|
||||||
|
|
||||||
i = ao2_iterator_init(users, 0);
|
i = ao2_iterator_init(users, 0);
|
||||||
while ((user = ao2_iterator_next(&i))) {
|
while ((user = ao2_iterator_next(&i))) {
|
||||||
@@ -9432,7 +9432,7 @@ static void prune_users(void)
|
|||||||
static void prune_peers(void)
|
static void prune_peers(void)
|
||||||
{
|
{
|
||||||
struct iax2_peer *peer;
|
struct iax2_peer *peer;
|
||||||
ao2_iterator i;
|
struct ao2_iterator i;
|
||||||
|
|
||||||
i = ao2_iterator_init(peers, 0);
|
i = ao2_iterator_init(peers, 0);
|
||||||
while ((peer = ao2_iterator_next(&i))) {
|
while ((peer = ao2_iterator_next(&i))) {
|
||||||
|
@@ -87,7 +87,7 @@ parameters. At the moment, this is done as follows:
|
|||||||
<b>Sample Usage:</b>
|
<b>Sample Usage:</b>
|
||||||
\code
|
\code
|
||||||
|
|
||||||
ao2_container *c;
|
struct ao2_container *c;
|
||||||
|
|
||||||
c = ao2_container_alloc(MAX_BUCKETS, my_hash_fn, my_cmp_fn);
|
c = ao2_container_alloc(MAX_BUCKETS, my_hash_fn, my_cmp_fn);
|
||||||
|
|
||||||
@@ -239,8 +239,8 @@ Operations on container include:
|
|||||||
iterate on a container
|
iterate on a container
|
||||||
this is done with the following sequence
|
this is done with the following sequence
|
||||||
|
|
||||||
ao2_container *c = ... // our container
|
struct ao2_container *c = ... // our container
|
||||||
ao2_iterator i;
|
struct ao2_iterator i;
|
||||||
void *o;
|
void *o;
|
||||||
|
|
||||||
i = ao2_iterator_init(c, flags);
|
i = ao2_iterator_init(c, flags);
|
||||||
@@ -320,14 +320,7 @@ typedef int (*ao2_callback_fn)(void *obj, void *arg, int flags);
|
|||||||
/*!
|
/*!
|
||||||
* Here start declarations of containers.
|
* Here start declarations of containers.
|
||||||
*/
|
*/
|
||||||
|
struct ao2_container;
|
||||||
/*!
|
|
||||||
* This structure contains the total number of buckets
|
|
||||||
* and variable size array of object pointers.
|
|
||||||
* It is opaque, defined in astobj2.c, so we only need
|
|
||||||
* a type declaration.
|
|
||||||
*/
|
|
||||||
typedef struct __ao2_container ao2_container;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Allocate and initialize a container
|
* Allocate and initialize a container
|
||||||
@@ -343,13 +336,13 @@ typedef struct __ao2_container ao2_container;
|
|||||||
*
|
*
|
||||||
* destructor is set implicitly.
|
* destructor is set implicitly.
|
||||||
*/
|
*/
|
||||||
ao2_container *ao2_container_alloc(const uint n_buckets,
|
struct ao2_container *ao2_container_alloc(const uint n_buckets,
|
||||||
ao2_hash_fn hash_fn, ao2_callback_fn cmp_fn);
|
ao2_hash_fn hash_fn, ao2_callback_fn cmp_fn);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns the number of elements in a container.
|
* Returns the number of elements in a container.
|
||||||
*/
|
*/
|
||||||
int ao2_container_count(ao2_container *c);
|
int ao2_container_count(struct ao2_container *c);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Here we have functions to manage objects.
|
* Here we have functions to manage objects.
|
||||||
@@ -375,8 +368,8 @@ int ao2_container_count(ao2_container *c);
|
|||||||
* matching behavior doesn't change.
|
* matching behavior doesn't change.
|
||||||
*/
|
*/
|
||||||
#define ao2_link(c, o) __ao2_link(c, o, 0)
|
#define ao2_link(c, o) __ao2_link(c, o, 0)
|
||||||
void *__ao2_link(ao2_container *c, void *newobj, int iax2_hack);
|
void *__ao2_link(struct ao2_container *c, void *newobj, int iax2_hack);
|
||||||
void *ao2_unlink(ao2_container *c, void *newobj);
|
void *ao2_unlink(struct ao2_container *c, void *newobj);
|
||||||
|
|
||||||
/*! \struct Used as return value if the flag OBJ_MULTIPLE is set */
|
/*! \struct Used as return value if the flag OBJ_MULTIPLE is set */
|
||||||
struct ao2_list {
|
struct ao2_list {
|
||||||
@@ -432,8 +425,8 @@ struct ao2_list {
|
|||||||
* be used to free the additional reference possibly created by this function.
|
* be used to free the additional reference possibly created by this function.
|
||||||
*/
|
*/
|
||||||
/* XXX order of arguments to find */
|
/* XXX order of arguments to find */
|
||||||
void *ao2_find(ao2_container *c, void *arg, enum search_flags flags);
|
void *ao2_find(struct ao2_container *c, void *arg, enum search_flags flags);
|
||||||
void *ao2_callback(ao2_container *c,
|
void *ao2_callback(struct ao2_container *c,
|
||||||
enum search_flags flags,
|
enum search_flags flags,
|
||||||
ao2_callback_fn cb_fn, void *arg);
|
ao2_callback_fn cb_fn, void *arg);
|
||||||
|
|
||||||
@@ -472,8 +465,8 @@ int ao2_match_by_addr(void *user_data, void *arg, int flags);
|
|||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
*
|
*
|
||||||
* ao2_container *c = ... // the container we want to iterate on
|
* struct ao2_container *c = ... // the container we want to iterate on
|
||||||
* ao2_iterator i;
|
* struct ao2_iterator i;
|
||||||
* struct my_obj *o;
|
* struct my_obj *o;
|
||||||
*
|
*
|
||||||
* i = ao2_iterator_init(c, flags);
|
* i = ao2_iterator_init(c, flags);
|
||||||
@@ -510,9 +503,9 @@ int ao2_match_by_addr(void *user_data, void *arg, int flags);
|
|||||||
* A freshly-initialized iterator has bucket=0, version = 0.
|
* A freshly-initialized iterator has bucket=0, version = 0.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct __ao2_iterator {
|
struct ao2_iterator {
|
||||||
/*! the container */
|
/*! the container */
|
||||||
ao2_container *c;
|
struct ao2_container *c;
|
||||||
/*! operation flags */
|
/*! operation flags */
|
||||||
int flags;
|
int flags;
|
||||||
#define F_AO2I_DONTLOCK 1 /*!< don't lock when iterating */
|
#define F_AO2I_DONTLOCK 1 /*!< don't lock when iterating */
|
||||||
@@ -524,11 +517,10 @@ struct __ao2_iterator {
|
|||||||
void *obj;
|
void *obj;
|
||||||
/*! container version when the object was created */
|
/*! container version when the object was created */
|
||||||
uint version;
|
uint version;
|
||||||
};
|
};
|
||||||
typedef struct __ao2_iterator ao2_iterator;
|
|
||||||
|
|
||||||
ao2_iterator ao2_iterator_init(ao2_container *c, int flags);
|
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags);
|
||||||
|
|
||||||
void *ao2_iterator_next(ao2_iterator *a);
|
void *ao2_iterator_next(struct ao2_iterator *a);
|
||||||
|
|
||||||
#endif /* _ASTERISK_ASTOBJ2_H */
|
#endif /* _ASTERISK_ASTOBJ2_H */
|
||||||
|
@@ -243,7 +243,7 @@ AST_LIST_HEAD_NOLOCK(bucket, bucket_list);
|
|||||||
* This will be more efficient as we can do the freelist management while
|
* This will be more efficient as we can do the freelist management while
|
||||||
* we hold the lock (that we need anyways).
|
* we hold the lock (that we need anyways).
|
||||||
*/
|
*/
|
||||||
struct __ao2_container {
|
struct ao2_container {
|
||||||
ao2_hash_fn hash_fn;
|
ao2_hash_fn hash_fn;
|
||||||
ao2_callback_fn cmp_fn;
|
ao2_callback_fn cmp_fn;
|
||||||
int n_buckets;
|
int n_buckets;
|
||||||
@@ -272,15 +272,15 @@ static int hash_zero(const void *user_obj, const int flags)
|
|||||||
/*
|
/*
|
||||||
* A container is just an object, after all!
|
* A container is just an object, after all!
|
||||||
*/
|
*/
|
||||||
ao2_container *
|
struct ao2_container *
|
||||||
ao2_container_alloc(const uint n_buckets, ao2_hash_fn hash_fn,
|
ao2_container_alloc(const uint n_buckets, ao2_hash_fn hash_fn,
|
||||||
ao2_callback_fn cmp_fn)
|
ao2_callback_fn cmp_fn)
|
||||||
{
|
{
|
||||||
/* XXX maybe consistency check on arguments ? */
|
/* XXX maybe consistency check on arguments ? */
|
||||||
/* compute the container size */
|
/* compute the container size */
|
||||||
size_t container_size = sizeof(ao2_container) + n_buckets * sizeof(struct bucket);
|
size_t container_size = sizeof(struct ao2_container) + n_buckets * sizeof(struct bucket);
|
||||||
|
|
||||||
ao2_container *c = ao2_alloc(container_size, container_destruct);
|
struct ao2_container *c = ao2_alloc(container_size, container_destruct);
|
||||||
|
|
||||||
if (!c)
|
if (!c)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -297,7 +297,7 @@ ao2_container_alloc(const uint n_buckets, ao2_hash_fn hash_fn,
|
|||||||
/*!
|
/*!
|
||||||
* return the number of elements in the container
|
* return the number of elements in the container
|
||||||
*/
|
*/
|
||||||
int ao2_container_count(ao2_container *c)
|
int ao2_container_count(struct ao2_container *c)
|
||||||
{
|
{
|
||||||
return c->elements;
|
return c->elements;
|
||||||
}
|
}
|
||||||
@@ -316,7 +316,7 @@ struct bucket_list {
|
|||||||
/*
|
/*
|
||||||
* link an object to a container
|
* link an object to a container
|
||||||
*/
|
*/
|
||||||
void *__ao2_link(ao2_container *c, void *user_data, int iax2_hack)
|
void *__ao2_link(struct ao2_container *c, void *user_data, int iax2_hack)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
/* create a new list entry */
|
/* create a new list entry */
|
||||||
@@ -361,7 +361,7 @@ int ao2_match_by_addr(void *user_data, void *arg, int flags)
|
|||||||
* Unlink an object from the container
|
* Unlink an object from the container
|
||||||
* and destroy the associated * ao2_bucket_list structure.
|
* and destroy the associated * ao2_bucket_list structure.
|
||||||
*/
|
*/
|
||||||
void *ao2_unlink(ao2_container *c, void *user_data)
|
void *ao2_unlink(struct ao2_container *c, void *user_data)
|
||||||
{
|
{
|
||||||
if (INTERNAL_OBJ(user_data) == NULL) /* safety check on the argument */
|
if (INTERNAL_OBJ(user_data) == NULL) /* safety check on the argument */
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -384,7 +384,7 @@ static int cb_true(void *user_data, void *arg, int flags)
|
|||||||
* \return Is a pointer to an object or to a list of object if OBJ_MULTIPLE is
|
* \return Is a pointer to an object or to a list of object if OBJ_MULTIPLE is
|
||||||
* specified.
|
* specified.
|
||||||
*/
|
*/
|
||||||
void *ao2_callback(ao2_container *c,
|
void *ao2_callback(struct ao2_container *c,
|
||||||
const enum search_flags flags,
|
const enum search_flags flags,
|
||||||
ao2_callback_fn cb_fn, void *arg)
|
ao2_callback_fn cb_fn, void *arg)
|
||||||
{
|
{
|
||||||
@@ -488,7 +488,7 @@ void *ao2_callback(ao2_container *c,
|
|||||||
/*!
|
/*!
|
||||||
* the find function just invokes the default callback with some reasonable flags.
|
* the find function just invokes the default callback with some reasonable flags.
|
||||||
*/
|
*/
|
||||||
void *ao2_find(ao2_container *c, void *arg, enum search_flags flags)
|
void *ao2_find(struct ao2_container *c, void *arg, enum search_flags flags)
|
||||||
{
|
{
|
||||||
return ao2_callback(c, flags, c->cmp_fn, arg);
|
return ao2_callback(c, flags, c->cmp_fn, arg);
|
||||||
}
|
}
|
||||||
@@ -496,9 +496,9 @@ void *ao2_find(ao2_container *c, void *arg, enum search_flags flags)
|
|||||||
/*!
|
/*!
|
||||||
* initialize an iterator so we start from the first object
|
* initialize an iterator so we start from the first object
|
||||||
*/
|
*/
|
||||||
ao2_iterator ao2_iterator_init(ao2_container *c, int flags)
|
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags)
|
||||||
{
|
{
|
||||||
ao2_iterator a = {
|
struct ao2_iterator a = {
|
||||||
.c = c,
|
.c = c,
|
||||||
.flags = flags
|
.flags = flags
|
||||||
};
|
};
|
||||||
@@ -509,7 +509,7 @@ ao2_iterator ao2_iterator_init(ao2_container *c, int flags)
|
|||||||
/*
|
/*
|
||||||
* move to the next element in the container.
|
* move to the next element in the container.
|
||||||
*/
|
*/
|
||||||
void * ao2_iterator_next(ao2_iterator *a)
|
void * ao2_iterator_next(struct ao2_iterator *a)
|
||||||
{
|
{
|
||||||
int lim;
|
int lim;
|
||||||
struct bucket_list *p = NULL;
|
struct bucket_list *p = NULL;
|
||||||
@@ -574,7 +574,7 @@ static int cd_cb(void *obj, void *arg, int flag)
|
|||||||
|
|
||||||
static void container_destruct(void *_c)
|
static void container_destruct(void *_c)
|
||||||
{
|
{
|
||||||
ao2_container *c = _c;
|
struct ao2_container *c = _c;
|
||||||
|
|
||||||
ao2_callback(c, OBJ_UNLINK, cd_cb, NULL);
|
ao2_callback(c, OBJ_UNLINK, cd_cb, NULL);
|
||||||
ast_atomic_fetchadd_int(&ao2.total_containers, -1);
|
ast_atomic_fetchadd_int(&ao2.total_containers, -1);
|
||||||
@@ -607,7 +607,7 @@ static int handle_astobj2_stats(int fd, int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
static int handle_astobj2_test(int fd, int argc, char *argv[])
|
static int handle_astobj2_test(int fd, int argc, char *argv[])
|
||||||
{
|
{
|
||||||
ao2_container *c1;
|
struct ao2_container *c1;
|
||||||
int i, lim;
|
int i, lim;
|
||||||
char *obj;
|
char *obj;
|
||||||
static int prof_id = -1;
|
static int prof_id = -1;
|
||||||
@@ -645,7 +645,7 @@ static int handle_astobj2_test(int fd, int argc, char *argv[])
|
|||||||
|
|
||||||
ast_cli(fd, "testing iterators, remove every second object\n");
|
ast_cli(fd, "testing iterators, remove every second object\n");
|
||||||
{
|
{
|
||||||
ao2_iterator ai;
|
struct ao2_iterator ai;
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
|
||||||
ai = ao2_iterator_init(c1, 0);
|
ai = ao2_iterator_init(c1, 0);
|
||||||
|
Reference in New Issue
Block a user