diff options
author | Martin Willi <martin@strongswan.org> | 2008-05-06 10:55:42 +0000 |
---|---|---|
committer | Martin Willi <martin@strongswan.org> | 2008-05-06 10:55:42 +0000 |
commit | ff6836716c1bacbca74bce6965a11523d35fab66 (patch) | |
tree | da326887ce2ab535259a8c707168a7f7e1ec3ea5 | |
parent | cc0cb9355390ab1120e3bb02a1bb17a1dbd41160 (diff) | |
download | strongswan-ff6836716c1bacbca74bce6965a11523d35fab66.tar.bz2 strongswan-ff6836716c1bacbca74bce6965a11523d35fab66.tar.xz |
returning reference pointer on get_ref()
-rw-r--r-- | src/charon/config/child_cfg.c | 5 | ||||
-rw-r--r-- | src/charon/config/child_cfg.h | 10 | ||||
-rw-r--r-- | src/charon/config/ike_cfg.c | 5 | ||||
-rw-r--r-- | src/charon/config/ike_cfg.h | 10 | ||||
-rw-r--r-- | src/charon/config/peer_cfg.c | 8 | ||||
-rw-r--r-- | src/charon/config/peer_cfg.h | 10 |
6 files changed, 19 insertions, 29 deletions
diff --git a/src/charon/config/child_cfg.c b/src/charon/config/child_cfg.c index e85814237..2c7201972 100644 --- a/src/charon/config/child_cfg.c +++ b/src/charon/config/child_cfg.c @@ -401,9 +401,10 @@ static diffie_hellman_group_t get_dh_group(private_child_cfg_t *this) /** * Implementation of child_cfg_t.get_name */ -static void get_ref(private_child_cfg_t *this) +static child_cfg_t* get_ref(private_child_cfg_t *this) { ref_get(&this->refcount); + return &this->public; } /** @@ -448,7 +449,7 @@ child_cfg_t *child_cfg_create(char *name, u_int32_t lifetime, this->public.get_close_action = (action_t (*) (child_cfg_t *))get_close_action; this->public.get_lifetime = (u_int32_t (*) (child_cfg_t *,bool))get_lifetime; this->public.get_dh_group = (diffie_hellman_group_t(*)(child_cfg_t*)) get_dh_group; - this->public.get_ref = (void (*) (child_cfg_t*))get_ref; + this->public.get_ref = (child_cfg_t* (*) (child_cfg_t*))get_ref; this->public.destroy = (void (*) (child_cfg_t*))destroy; this->name = strdup(name); diff --git a/src/charon/config/child_cfg.h b/src/charon/config/child_cfg.h index 688eac720..3d4889b53 100644 --- a/src/charon/config/child_cfg.h +++ b/src/charon/config/child_cfg.h @@ -214,15 +214,11 @@ struct child_cfg_t { diffie_hellman_group_t (*get_dh_group)(child_cfg_t *this); /** - * Get a new reference. + * Increase the reference count. * - * Get a new reference to this child_cfg by increasing - * it's internal reference counter. - * Do not call get_ref or any other function until you - * already have a reference. Otherwise the object may get - * destroyed while calling get_ref(), + * @return reference to this */ - void (*get_ref) (child_cfg_t *this); + child_cfg_t* (*get_ref) (child_cfg_t *this); /** * Destroys the child_cfg object. diff --git a/src/charon/config/ike_cfg.c b/src/charon/config/ike_cfg.c index ec08b9730..b92cb98c6 100644 --- a/src/charon/config/ike_cfg.c +++ b/src/charon/config/ike_cfg.c @@ -226,9 +226,10 @@ static bool equals(private_ike_cfg_t *this, private_ike_cfg_t *other) /** * Implementation of ike_cfg_t.get_ref. */ -static void get_ref(private_ike_cfg_t *this) +static ike_cfg_t* get_ref(private_ike_cfg_t *this) { ref_get(&this->refcount); + return &this->public; } /** @@ -264,7 +265,7 @@ ike_cfg_t *ike_cfg_create(bool certreq, bool force_encap, this->public.select_proposal = (proposal_t*(*)(ike_cfg_t*,linked_list_t*))select_proposal; this->public.get_dh_group = (diffie_hellman_group_t(*)(ike_cfg_t*)) get_dh_group; this->public.equals = (bool(*)(ike_cfg_t*,ike_cfg_t*)) equals; - this->public.get_ref = (void(*)(ike_cfg_t*))get_ref; + this->public.get_ref = (ike_cfg_t*(*)(ike_cfg_t*))get_ref; this->public.destroy = (void(*)(ike_cfg_t*))destroy; /* private variables */ diff --git a/src/charon/config/ike_cfg.h b/src/charon/config/ike_cfg.h index 3bd64f27f..d1cae000b 100644 --- a/src/charon/config/ike_cfg.h +++ b/src/charon/config/ike_cfg.h @@ -113,15 +113,11 @@ struct ike_cfg_t { bool (*equals)(ike_cfg_t *this, ike_cfg_t *other); /** - * Get a new reference to this ike_cfg. + * Increase reference count. * - * Get a new reference to this ike_cfg by increasing - * it's internal reference counter. - * Do not call get_ref or any other function until you - * already have a reference. Otherwise the object may get - * destroyed while calling get_ref(), + * @return reference to this */ - void (*get_ref) (ike_cfg_t *this); + ike_cfg_t* (*get_ref) (ike_cfg_t *this); /** * Destroys a ike_cfg_t object. diff --git a/src/charon/config/peer_cfg.c b/src/charon/config/peer_cfg.c index 9c32a2e43..c290c7919 100644 --- a/src/charon/config/peer_cfg.c +++ b/src/charon/config/peer_cfg.c @@ -266,8 +266,7 @@ static child_cfg_t* select_child_cfg(private_peer_cfg_t *this, if (contains_ts(current, TRUE, my_ts, my_host) && contains_ts(current, FALSE, other_ts, other_host)) { - found = current; - found->get_ref(found); + found = current->get_ref(current); break; } } @@ -487,9 +486,10 @@ static bool equals(private_peer_cfg_t *this, private_peer_cfg_t *other) /** * Implements peer_cfg_t.get_ref. */ -static void get_ref(private_peer_cfg_t *this) +static peer_cfg_t* get_ref(private_peer_cfg_t *this) { ref_get(&this->refcount); + return &this->public; } /** @@ -556,7 +556,7 @@ peer_cfg_t *peer_cfg_create(char *name, u_int ike_version, ike_cfg_t *ike_cfg, this->public.get_pool = (char*(*)(peer_cfg_t*))get_pool; this->public.get_auth = (auth_info_t*(*)(peer_cfg_t*))get_auth; this->public.equals = (bool(*)(peer_cfg_t*, peer_cfg_t *other))equals; - this->public.get_ref = (void(*)(peer_cfg_t *))get_ref; + this->public.get_ref = (peer_cfg_t*(*)(peer_cfg_t *))get_ref; this->public.destroy = (void(*)(peer_cfg_t *))destroy; #ifdef ME this->public.is_mediation = (bool (*) (peer_cfg_t *))is_mediation; diff --git a/src/charon/config/peer_cfg.h b/src/charon/config/peer_cfg.h index 5e12fbfd2..795ca1272 100644 --- a/src/charon/config/peer_cfg.h +++ b/src/charon/config/peer_cfg.h @@ -322,15 +322,11 @@ struct peer_cfg_t { bool (*equals)(peer_cfg_t *this, peer_cfg_t *other); /** - * Get a new reference. + * Increase reference count. * - * Get a new reference to this peer_cfg by increasing - * it's internal reference counter. - * Do not call get_ref or any other function until you - * already have a reference. Otherwise the object may get - * destroyed while calling get_ref(), + * @return reference to this */ - void (*get_ref) (peer_cfg_t *this); + peer_cfg_t* (*get_ref) (peer_cfg_t *this); /** * Destroys the peer_cfg object. |