- changed memory allocator functions to own allocator calls

This commit is contained in:
Jan Hutter
2005-11-09 09:11:06 +00:00
parent c1ca1ee042
commit 7953866962
22 changed files with 606 additions and 606 deletions
+31 -31
View File
@@ -1,8 +1,8 @@
/**
* @file send_queue.c
*
*
* @brief Send-Queue based on linked_list_t
*
*
*/
/*
@@ -19,43 +19,43 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include <pthread.h>
#include "send_queue.h"
#include "linked_list.h"
/**
* @brief Private Variables and Functions of send_queue class
*
*
*/
typedef struct private_send_queue_s private_send_queue_t;
struct private_send_queue_s {
/**
* Public part of the send_queue_t object
*/
send_queue_t public;
/**
* The packets are stored in a linked list
*/
linked_list_t *list;
/**
* access to linked_list is locked through this mutex
*/
pthread_mutex_t mutex;
/**
* If the queue is empty a thread has to wait
* This condvar is used to wake up such a thread
*/
pthread_cond_t condvar;
pthread_cond_t condvar;
};
/**
* @brief implements function get_count of send_queue_t
*/
@@ -66,7 +66,7 @@ static status_t get_count(private_send_queue_t *this, int *count)
pthread_mutex_unlock(&(this->mutex));
return SUCCESS;
}
/**
* @brief implements function get of send_queue_t
*/
@@ -83,7 +83,7 @@ static status_t get(private_send_queue_t *this, packet_t **packet)
pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock, (void*)&(this->mutex));
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
pthread_cond_wait( &(this->condvar), &(this->mutex));
/* reset cancellation, remove mutex-unlock handler (without executing) */
pthread_setcancelstate(oldstate, NULL);
pthread_cleanup_pop(0);
@@ -93,7 +93,7 @@ static status_t get(private_send_queue_t *this, packet_t **packet)
pthread_mutex_unlock(&(this->mutex));
return SUCCESS;
}
/**
* @brief implements function add of send_queue_t
*/
@@ -105,18 +105,18 @@ static status_t add(private_send_queue_t *this, packet_t *packet)
pthread_mutex_unlock(&(this->mutex));
return SUCCESS;
}
/**
* @brief implements function destroy of send_queue_t
*
*
*/
static status_t destroy (private_send_queue_t *this)
{
int count;
this->list->get_count(this->list,&count);
/* destroy all packets in list before destroying list */
while (count > 0)
while (count > 0)
{
packet_t *packet;
if (this->list->remove_first(this->list,(void *) &packet) != SUCCESS)
@@ -128,17 +128,17 @@ static status_t destroy (private_send_queue_t *this)
this->list->get_count(this->list,&count);
}
this->list->destroy(this->list);
pthread_mutex_destroy(&(this->mutex));
pthread_cond_destroy(&(this->condvar));
pfree(this);
allocator_free(this);
return SUCCESS;
}
/*
*
*
* Documented in header
*/
send_queue_t *send_queue_create()
@@ -148,22 +148,22 @@ send_queue_t *send_queue_create()
{
return NULL;
}
private_send_queue_t *this = alloc_thing(private_send_queue_t, "private_send_queue_t");
private_send_queue_t *this = allocator_alloc_thing(private_send_queue_t, "private_send_queue_t");
if (this == NULL)
{
linked_list->destroy(linked_list);
return NULL;
}
this->public.get_count = (status_t(*)(send_queue_t*, int*)) get_count;
this->public.get = (status_t(*)(send_queue_t*, packet_t**)) get;
this->public.add = (status_t(*)(send_queue_t*, packet_t*)) add;
this->public.destroy = (status_t(*)(send_queue_t*)) destroy;
this->list = linked_list;
pthread_mutex_init(&(this->mutex), NULL);
pthread_cond_init(&(this->condvar), NULL);
return (&this->public);
}