- return value cleanup
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file host.c
|
||||
*
|
||||
* @brief host object, identifies a host and defines some useful functions on it.
|
||||
* @brief Implementation of host_t.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -110,28 +110,20 @@ static u_int16_t get_port(private_host_t *this)
|
||||
/**
|
||||
* Implements host_t.destroy
|
||||
*/
|
||||
static status_t destroy(private_host_t *this)
|
||||
static void destroy(private_host_t *this)
|
||||
{
|
||||
allocator_free(this);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements host_t.clone.
|
||||
*/
|
||||
static status_t clone(private_host_t *this, host_t **other)
|
||||
static private_host_t *clone(private_host_t *this)
|
||||
{
|
||||
private_host_t *new = allocator_alloc_thing(private_host_t);
|
||||
|
||||
if (new == NULL)
|
||||
{
|
||||
return OUT_OF_RES;
|
||||
}
|
||||
|
||||
memcpy(new, this, sizeof(private_host_t));
|
||||
*other = (host_t*)new;
|
||||
|
||||
return SUCCESS;
|
||||
return new;
|
||||
}
|
||||
|
||||
|
||||
@@ -141,17 +133,13 @@ static status_t clone(private_host_t *this, host_t **other)
|
||||
host_t *host_create(int family, char *address, u_int16_t port)
|
||||
{
|
||||
private_host_t *this = allocator_alloc_thing(private_host_t);
|
||||
if (this == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
this->public.get_sockaddr = (sockaddr_t* (*) (host_t*))get_sockaddr;
|
||||
this->public.get_sockaddr_len = (socklen_t*(*) (host_t*))get_sockaddr_len;
|
||||
this->public.clone = (status_t (*) (host_t*, host_t**))clone;
|
||||
this->public.clone = (host_t* (*) (host_t*))clone;
|
||||
this->public.get_address = (char* (*) (host_t *))get_address;
|
||||
this->public.get_port = (u_int16_t (*) (host_t *))get_port;
|
||||
this->public.destroy = (status_t (*) (host_t*))destroy;
|
||||
this->public.destroy = (void (*) (host_t*))destroy;
|
||||
|
||||
this->family = family;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* @file host.h
|
||||
*
|
||||
* @brief host object, identifies a host and defines some useful functions on it.
|
||||
* @brief Interface of host_t.
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -36,19 +36,18 @@
|
||||
typedef struct host_t host_t;
|
||||
/**
|
||||
* @brief Representates a Host
|
||||
*
|
||||
* Host object, identifies a host and defines some useful functions on it.
|
||||
*/
|
||||
struct host_t {
|
||||
/**
|
||||
* @brief Build a clone of this host object.
|
||||
*
|
||||
* @param this object to clone
|
||||
* @param [out]other address where to allocate the clone
|
||||
* @return
|
||||
* - SUCCESS, or
|
||||
* - OUT_OF_RES
|
||||
* @return cloned host
|
||||
*/
|
||||
|
||||
status_t (*clone) (host_t *this, host_t **other);
|
||||
host_t *(*clone) (host_t *this);
|
||||
|
||||
/**
|
||||
* @brief Get a pointer to the internal sockaddr struct.
|
||||
*
|
||||
@@ -100,7 +99,7 @@ struct host_t {
|
||||
* @param this calling
|
||||
* @return SUCCESS in any case
|
||||
*/
|
||||
status_t (*destroy) (host_t *this);
|
||||
void (*destroy) (host_t *this);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -112,10 +111,9 @@ struct host_t {
|
||||
* @param address string of an address, such as "152.96.193.130"
|
||||
* @param port port number
|
||||
* @return the host_t object or NULL, when
|
||||
* not enough ressources, or
|
||||
* family not supported.
|
||||
*/
|
||||
host_t *host_create(int family, char *address, u_int16_t port);
|
||||
|
||||
|
||||
|
||||
#endif /*HOST_H_*/
|
||||
|
||||
@@ -76,7 +76,7 @@ static status_t clone (private_packet_t *this, packet_t **clone)
|
||||
|
||||
if (this->public.destination != NULL)
|
||||
{
|
||||
this->public.destination->clone(this->public.destination, &(other->destination));
|
||||
other->destination = this->public.destination->clone(this->public.destination);
|
||||
}
|
||||
else {
|
||||
other->destination = NULL;
|
||||
@@ -84,7 +84,7 @@ static status_t clone (private_packet_t *this, packet_t **clone)
|
||||
|
||||
if (this->public.source != NULL)
|
||||
{
|
||||
this->public.source->clone(this->public.source, &(other->source));
|
||||
other->source = this->public.source->clone(this->public.source);
|
||||
}
|
||||
else {
|
||||
other->source = NULL;
|
||||
|
||||
Reference in New Issue
Block a user