returning reference pointer on get_ref()

This commit is contained in:
Martin Willi
2008-05-06 10:55:42 +00:00
parent cc0cb93553
commit ff6836716c
6 changed files with 19 additions and 29 deletions
+3 -2
View File
@@ -401,9 +401,10 @@ static diffie_hellman_group_t get_dh_group(private_child_cfg_t *this)
/** /**
* Implementation of child_cfg_t.get_name * 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); 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_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_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_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->public.destroy = (void (*) (child_cfg_t*))destroy;
this->name = strdup(name); this->name = strdup(name);
+3 -7
View File
@@ -214,15 +214,11 @@ struct child_cfg_t {
diffie_hellman_group_t (*get_dh_group)(child_cfg_t *this); 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 * @return reference to this
* 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(),
*/ */
void (*get_ref) (child_cfg_t *this); child_cfg_t* (*get_ref) (child_cfg_t *this);
/** /**
* Destroys the child_cfg object. * Destroys the child_cfg object.
+3 -2
View File
@@ -226,9 +226,10 @@ static bool equals(private_ike_cfg_t *this, private_ike_cfg_t *other)
/** /**
* Implementation of ike_cfg_t.get_ref. * 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); 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.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.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.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; this->public.destroy = (void(*)(ike_cfg_t*))destroy;
/* private variables */ /* private variables */
+3 -7
View File
@@ -113,15 +113,11 @@ struct ike_cfg_t {
bool (*equals)(ike_cfg_t *this, ike_cfg_t *other); 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 * @return reference to this
* 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(),
*/ */
void (*get_ref) (ike_cfg_t *this); ike_cfg_t* (*get_ref) (ike_cfg_t *this);
/** /**
* Destroys a ike_cfg_t object. * Destroys a ike_cfg_t object.
+4 -4
View File
@@ -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) && if (contains_ts(current, TRUE, my_ts, my_host) &&
contains_ts(current, FALSE, other_ts, other_host)) contains_ts(current, FALSE, other_ts, other_host))
{ {
found = current; found = current->get_ref(current);
found->get_ref(found);
break; break;
} }
} }
@@ -487,9 +486,10 @@ static bool equals(private_peer_cfg_t *this, private_peer_cfg_t *other)
/** /**
* Implements peer_cfg_t.get_ref. * 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); 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_pool = (char*(*)(peer_cfg_t*))get_pool;
this->public.get_auth = (auth_info_t*(*)(peer_cfg_t*))get_auth; 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.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; this->public.destroy = (void(*)(peer_cfg_t *))destroy;
#ifdef ME #ifdef ME
this->public.is_mediation = (bool (*) (peer_cfg_t *))is_mediation; this->public.is_mediation = (bool (*) (peer_cfg_t *))is_mediation;
+3 -7
View File
@@ -322,15 +322,11 @@ struct peer_cfg_t {
bool (*equals)(peer_cfg_t *this, peer_cfg_t *other); 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 * @return reference to this
* 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(),
*/ */
void (*get_ref) (peer_cfg_t *this); peer_cfg_t* (*get_ref) (peer_cfg_t *this);
/** /**
* Destroys the peer_cfg object. * Destroys the peer_cfg object.