- 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
+2 -2
View File
@@ -55,7 +55,7 @@ static status_t destroy (private_configuration_t *this)
{ {
return FAILED; return FAILED;
} }
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
@@ -64,7 +64,7 @@ static status_t destroy (private_configuration_t *this)
*/ */
configuration_t * configuration_create() configuration_t * configuration_create()
{ {
private_configuration_t *this = alloc_thing(private_configuration_t, "private_configuration_t"); private_configuration_t *this = allocator_alloc_thing(private_configuration_t, "private_configuration_t");
if (this == NULL) if (this == NULL)
{ {
return NULL; return NULL;
+4 -4
View File
@@ -71,7 +71,7 @@ static status_t event_destroy(event_t *event)
{ {
return FAILED; return FAILED;
} }
pfree(event); allocator_free(event);
return SUCCESS; return SUCCESS;
} }
@@ -85,7 +85,7 @@ static status_t event_destroy(event_t *event)
*/ */
static event_t *event_create(timeval_t time, job_t *job) static event_t *event_create(timeval_t time, job_t *job)
{ {
event_t *this = alloc_thing(event_t, "event_t"); event_t *this = allocator_alloc_thing(event_t, "event_t");
this->destroy = event_destroy; this->destroy = event_destroy;
@@ -345,7 +345,7 @@ static status_t event_queue_destroy(private_event_queue_t *this)
pthread_cond_destroy(&(this->condvar)); pthread_cond_destroy(&(this->condvar));
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
@@ -361,7 +361,7 @@ event_queue_t *event_queue_create()
return NULL; return NULL;
} }
private_event_queue_t *this = alloc_thing(private_event_queue_t, "private_event_queue_t"); private_event_queue_t *this = allocator_alloc_thing(private_event_queue_t, "private_event_queue_t");
if (this == NULL) if (this == NULL)
{ {
linked_list->destroy(linked_list); linked_list->destroy(linked_list);
+4 -4
View File
@@ -106,7 +106,7 @@ static status_t generate_u_int_type (private_generator_t *this,encoding_type_t i
*/ */
static status_t generate (private_generator_t *this,void * data_struct,encoding_rule_t *encoding_rules, size_t encoding_rules_count, chunk_t *data) static status_t generate (private_generator_t *this,void * data_struct,encoding_rule_t *encoding_rules, size_t encoding_rules_count, chunk_t *data)
{ {
u_int8_t * buffer = alloc_bytes(GENERATOR_DATA_BUFFER_SIZE, "generator buffer"); u_int8_t * buffer = allocator_alloc(GENERATOR_DATA_BUFFER_SIZE, "generator buffer");
u_int8_t * out_position = buffer; u_int8_t * out_position = buffer;
u_int8_t * roof_position = buffer + GENERATOR_DATA_BUFFER_SIZE; u_int8_t * roof_position = buffer + GENERATOR_DATA_BUFFER_SIZE;
size_t current_bit = 0; size_t current_bit = 0;
@@ -138,7 +138,7 @@ static status_t generate (private_generator_t *this,void * data_struct,encoding_
} }
if (status != SUCCESS) if (status != SUCCESS)
{ {
pfree(buffer); allocator_free(buffer);
return status; return status;
} }
} }
@@ -172,7 +172,7 @@ static status_t destroy(private_generator_t *this)
return FAILED; return FAILED;
} }
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
@@ -188,7 +188,7 @@ generator_t * generator_create(payload_info_t ** payload_infos)
return NULL; return NULL;
} }
this = alloc_thing(private_generator_t,"private_generator_t"); this = allocator_alloc_thing(private_generator_t,"private_generator_t");
if (this == NULL) if (this == NULL)
{ {
return NULL; return NULL;
+4 -4
View File
@@ -135,7 +135,7 @@ static status_t destroy (private_ike_sa_t *this)
this->child_sas->destroy(this->child_sas); this->child_sas->destroy(this->child_sas);
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
@@ -145,7 +145,7 @@ static status_t destroy (private_ike_sa_t *this)
*/ */
ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id) ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id)
{ {
private_ike_sa_t *this = alloc_thing(private_ike_sa_t, "private_ike_sa_t"); private_ike_sa_t *this = allocator_alloc_thing(private_ike_sa_t, "private_ike_sa_t");
if (this == NULL) if (this == NULL)
{ {
return NULL; return NULL;
@@ -162,7 +162,7 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id)
/* initialize private fields */ /* initialize private fields */
if (ike_sa_id->clone(ike_sa_id,&(this->ike_sa_id)) != SUCCESS) if (ike_sa_id->clone(ike_sa_id,&(this->ike_sa_id)) != SUCCESS)
{ {
pfree(this); allocator_free(this);
return NULL; return NULL;
} }
@@ -170,7 +170,7 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id)
if (this->child_sas == NULL) if (this->child_sas == NULL)
{ {
this->ike_sa_id->destroy(this->ike_sa_id); this->ike_sa_id->destroy(this->ike_sa_id);
pfree(this); allocator_free(this);
return NULL; return NULL;
} }
+2 -2
View File
@@ -173,7 +173,7 @@ static status_t destroy (private_ike_sa_id_t *this)
{ {
return FAILED; return FAILED;
} }
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
@@ -182,7 +182,7 @@ static status_t destroy (private_ike_sa_id_t *this)
*/ */
ike_sa_id_t * ike_sa_id_create(spi_t initiator_spi, spi_t responder_spi, ike_sa_role_t role) ike_sa_id_t * ike_sa_id_create(spi_t initiator_spi, spi_t responder_spi, ike_sa_role_t role)
{ {
private_ike_sa_id_t *this = alloc_thing(private_ike_sa_id_t, "private_ike_sa_id_t"); private_ike_sa_id_t *this = allocator_alloc_thing(private_ike_sa_id_t, "private_ike_sa_id_t");
if (this == NULL) if (this == NULL)
{ {
return NULL; return NULL;
+5 -5
View File
@@ -62,7 +62,7 @@ static status_t ike_sa_entry_destroy(ike_sa_entry_t *this)
{ {
this->ike_sa->destroy(this->ike_sa); this->ike_sa->destroy(this->ike_sa);
this->ike_sa_id->destroy(this->ike_sa_id); this->ike_sa_id->destroy(this->ike_sa_id);
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
@@ -78,7 +78,7 @@ static status_t ike_sa_entry_destroy(ike_sa_entry_t *this)
*/ */
ike_sa_entry_t *ike_sa_entry_create(ike_sa_id_t *ike_sa_id) ike_sa_entry_t *ike_sa_entry_create(ike_sa_id_t *ike_sa_id)
{ {
ike_sa_entry_t *this = alloc_thing(ike_sa_entry_t, "ike_sa_entry_t"); ike_sa_entry_t *this = allocator_alloc_thing(ike_sa_entry_t, "ike_sa_entry_t");
this->destroy = ike_sa_entry_destroy; this->destroy = ike_sa_entry_destroy;
this->waiting_threads = 0; this->waiting_threads = 0;
@@ -504,7 +504,7 @@ static status_t destroy(private_ike_sa_manager_t *this)
list->destroy(list); list->destroy(list);
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
@@ -512,7 +512,7 @@ static status_t destroy(private_ike_sa_manager_t *this)
ike_sa_manager_t *ike_sa_manager_create() ike_sa_manager_t *ike_sa_manager_create()
{ {
private_ike_sa_manager_t *this = alloc_thing(private_ike_sa_manager_t, "private_ike_sa_manager_t"); private_ike_sa_manager_t *this = allocator_alloc_thing(private_ike_sa_manager_t, "private_ike_sa_manager_t");
/* assign public functions */ /* assign public functions */
this->public.destroy = (status_t(*)(ike_sa_manager_t*))destroy; this->public.destroy = (status_t(*)(ike_sa_manager_t*))destroy;
@@ -529,7 +529,7 @@ ike_sa_manager_t *ike_sa_manager_create()
this->list = linked_list_create(); this->list = linked_list_create();
if (this->list == NULL) if (this->list == NULL)
{ {
pfree(this); allocator_free(this);
return NULL; return NULL;
} }
+2 -2
View File
@@ -32,7 +32,7 @@
*/ */
static status_t job_destroy(job_t *job) static status_t job_destroy(job_t *job)
{ {
pfree(job); allocator_free(job);
return SUCCESS; return SUCCESS;
} }
@@ -41,7 +41,7 @@ static status_t job_destroy(job_t *job)
*/ */
job_t *job_create(job_type_t type, void *assigned_data) job_t *job_create(job_type_t type, void *assigned_data)
{ {
job_t *this = alloc_thing(job_t, "job_t"); job_t *this = allocator_alloc_thing(job_t, "job_t");
this->destroy = job_destroy; this->destroy = job_destroy;
+2 -2
View File
@@ -133,7 +133,7 @@ static status_t job_queue_destroy (private_job_queue_t *this)
pthread_cond_destroy(&(this->condvar)); pthread_cond_destroy(&(this->condvar));
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
@@ -149,7 +149,7 @@ job_queue_t *job_queue_create()
return NULL; return NULL;
} }
private_job_queue_t *this = alloc_thing(private_job_queue_t, "private_job_queue_t"); private_job_queue_t *this = allocator_alloc_thing(private_job_queue_t, "private_job_queue_t");
if (this == NULL) if (this == NULL)
{ {
linked_list->destroy(linked_list); linked_list->destroy(linked_list);
+7 -7
View File
@@ -71,7 +71,7 @@ static status_t linked_list_element_destroy(linked_list_element_t *this)
{ {
return FAILED; return FAILED;
} }
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
@@ -87,7 +87,7 @@ static status_t linked_list_element_destroy(linked_list_element_t *this)
linked_list_element_t *linked_list_element_create(void *value) linked_list_element_t *linked_list_element_create(void *value)
{ {
linked_list_element_t *this = alloc_thing(linked_list_element_t, "linked_list_element_t"); linked_list_element_t *this = allocator_alloc_thing(linked_list_element_t, "linked_list_element_t");
if (this == NULL) if (this == NULL)
{ {
@@ -232,7 +232,7 @@ static status_t iterator_destroy(private_linked_list_iterator_t *this)
{ {
return FAILED; return FAILED;
} }
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
@@ -252,7 +252,7 @@ static status_t get_count(private_linked_list_t *this, int *count)
static status_t create_iterator (private_linked_list_t *linked_list, linked_list_iterator_t **iterator,bool forward) static status_t create_iterator (private_linked_list_t *linked_list, linked_list_iterator_t **iterator,bool forward)
{ {
private_linked_list_iterator_t *this = alloc_thing(private_linked_list_iterator_t, "private_linked_list_iterator_t"); private_linked_list_iterator_t *this = allocator_alloc_thing(private_linked_list_iterator_t, "private_linked_list_iterator_t");
if (this == NULL) if (this == NULL)
{ {
@@ -669,11 +669,11 @@ static status_t linked_list_destroy(private_linked_list_t *this)
* if list is not empty when deleting */ * if list is not empty when deleting */
if (this->public.remove_first(&(this->public),&value) != SUCCESS) if (this->public.remove_first(&(this->public),&value) != SUCCESS)
{ {
pfree(this); allocator_free(this);
return FAILED; return FAILED;
} }
} }
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
@@ -682,7 +682,7 @@ static status_t linked_list_destroy(private_linked_list_t *this)
*/ */
linked_list_t *linked_list_create() linked_list_t *linked_list_create()
{ {
private_linked_list_t *this = alloc_thing(private_linked_list_t, "private_linked_list_t"); private_linked_list_t *this = allocator_alloc_thing(private_linked_list_t, "private_linked_list_t");
this->public.get_count = (status_t (*) (linked_list_t *linked_list, int *count)) get_count; this->public.get_count = (status_t (*) (linked_list_t *linked_list, int *count)) get_count;
this->public.create_iterator = (status_t (*) (linked_list_t *linked_list, linked_list_iterator_t **iterator,bool forward)) create_iterator; this->public.create_iterator = (status_t (*) (linked_list_t *linked_list, linked_list_iterator_t **iterator,bool forward)) create_iterator;
+2 -2
View File
@@ -54,7 +54,7 @@ static status_t destroy (private_message_t *this)
{ {
return FAILED; return FAILED;
} }
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
@@ -63,7 +63,7 @@ static status_t destroy (private_message_t *this)
*/ */
message_t * message_create() message_t * message_create()
{ {
private_message_t *this = alloc_thing(private_message_t, "private_message_t"); private_message_t *this = allocator_alloc_thing(private_message_t, "private_message_t");
if (this == NULL) if (this == NULL)
{ {
return NULL; return NULL;
+4 -4
View File
@@ -27,9 +27,9 @@ static status_t destroy(packet_t *this)
{ {
if (this->data.ptr != NULL) if (this->data.ptr != NULL)
{ {
pfree(this->data.ptr); allocator_free(this->data.ptr);
} }
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
@@ -68,7 +68,7 @@ status_t set_source(packet_t *this, char *address, u_int16_t port)
packet_t *packet_create(int family) packet_t *packet_create(int family)
{ {
packet_t *this = alloc_thing(packet_t, "packet_t"); packet_t *this = allocator_alloc_thing(packet_t, "packet_t");
this->destroy = destroy; this->destroy = destroy;
this->set_destination = set_destination; this->set_destination = set_destination;
@@ -81,7 +81,7 @@ packet_t *packet_create(int family)
this->sockaddr_len = sizeof(struct sockaddr_in); this->sockaddr_len = sizeof(struct sockaddr_in);
break; break;
default: /* not supported */ default: /* not supported */
pfree(this); allocator_free(this);
return NULL; return NULL;
} }
+3 -3
View File
@@ -98,20 +98,20 @@ static status_t destroy(private_receiver_t *this)
pthread_join(this->assigned_thread, NULL); pthread_join(this->assigned_thread, NULL);
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
receiver_t * receiver_create() receiver_t * receiver_create()
{ {
private_receiver_t *this = alloc_thing(private_receiver_t,"private_receiver_t"); private_receiver_t *this = allocator_alloc_thing(private_receiver_t,"private_receiver_t");
this->public.destroy = (status_t(*)(receiver_t*)) destroy; this->public.destroy = (status_t(*)(receiver_t*)) destroy;
if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))receiver_thread_function, this) != 0) if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))receiver_thread_function, this) != 0)
{ {
/* thread could not be created */ /* thread could not be created */
pfree(this); allocator_free(this);
return NULL; return NULL;
} }
+3 -3
View File
@@ -78,20 +78,20 @@ static status_t destroy(private_scheduler_t *this)
pthread_join(this->assigned_thread, NULL); pthread_join(this->assigned_thread, NULL);
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
scheduler_t * scheduler_create() scheduler_t * scheduler_create()
{ {
private_scheduler_t *this = alloc_thing(private_scheduler_t,"private_scheduler_t"); private_scheduler_t *this = allocator_alloc_thing(private_scheduler_t,"private_scheduler_t");
this->public.destroy = (status_t(*)(scheduler_t*)) destroy; this->public.destroy = (status_t(*)(scheduler_t*)) destroy;
if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))scheduler_thread_function, this) != 0) if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))scheduler_thread_function, this) != 0)
{ {
/* thread could not be created */ /* thread could not be created */
pfree(this); allocator_free(this);
return NULL; return NULL;
} }
+2 -2
View File
@@ -133,7 +133,7 @@ static status_t destroy (private_send_queue_t *this)
pthread_cond_destroy(&(this->condvar)); pthread_cond_destroy(&(this->condvar));
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
@@ -149,7 +149,7 @@ send_queue_t *send_queue_create()
return NULL; 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) if (this == NULL)
{ {
linked_list->destroy(linked_list); linked_list->destroy(linked_list);
+3 -3
View File
@@ -94,20 +94,20 @@ static status_t destroy(private_sender_t *this)
pthread_join(this->assigned_thread, NULL); pthread_join(this->assigned_thread, NULL);
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
sender_t * sender_create() sender_t * sender_create()
{ {
private_sender_t *this = alloc_thing(private_sender_t,"private_sender_t"); private_sender_t *this = allocator_alloc_thing(private_sender_t,"private_sender_t");
this->public.destroy = (status_t(*)(sender_t*)) destroy; this->public.destroy = (status_t(*)(sender_t*)) destroy;
if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))sender_thread_function, this) != 0) if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))sender_thread_function, this) != 0)
{ {
/* thread could not be created */ /* thread could not be created */
pfree(this); allocator_free(this);
return NULL; return NULL;
} }
+5 -5
View File
@@ -83,7 +83,7 @@ status_t receiver(private_socket_t *this, packet_t **packet)
} }
/* fill in packet */ /* fill in packet */
pkt->data.ptr = alloc_bytes(pkt->data.len, "data in packet_t"); pkt->data.ptr = allocator_alloc(pkt->data.len, "data in packet_t");
memcpy(pkt->data.ptr, buffer, pkt->data.len); memcpy(pkt->data.ptr, buffer, pkt->data.len);
/* return packet */ /* return packet */
@@ -117,14 +117,14 @@ status_t sender(private_socket_t *this, packet_t *packet)
status_t destroy(private_socket_t *this) status_t destroy(private_socket_t *this)
{ {
close(this->socket_fd); close(this->socket_fd);
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
socket_t *socket_create(u_int16_t port) socket_t *socket_create(u_int16_t port)
{ {
private_socket_t *this = alloc_thing(private_socket_t, "private_socket_t"); private_socket_t *this = allocator_alloc_thing(private_socket_t, "private_socket_t");
struct sockaddr_in addr; struct sockaddr_in addr;
/* public functions */ /* public functions */
@@ -135,7 +135,7 @@ socket_t *socket_create(u_int16_t port)
/* create default ipv4 socket */ /* create default ipv4 socket */
this->socket_fd = socket(PF_INET, SOCK_DGRAM, 0); this->socket_fd = socket(PF_INET, SOCK_DGRAM, 0);
if (this->socket_fd < 0) { if (this->socket_fd < 0) {
pfree(this); allocator_free(this);
/* TODO: log detailed error */ /* TODO: log detailed error */
return NULL; return NULL;
} }
@@ -145,7 +145,7 @@ socket_t *socket_create(u_int16_t port)
addr.sin_addr.s_addr = INADDR_ANY; addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_port = htons(port); addr.sin_port = htons(port);
if (bind(this->socket_fd,(struct sockaddr*)&addr, sizeof(addr)) < 0) { if (bind(this->socket_fd,(struct sockaddr*)&addr, sizeof(addr)) < 0) {
pfree(this); allocator_free(this);
/* TODO: log detailed error */ /* TODO: log detailed error */
return NULL; return NULL;
} }
+2 -2
View File
@@ -173,13 +173,13 @@ static status_t destroy(tester_t *tester)
{ {
private_tester_t *this = (private_tester_t*) tester; private_tester_t *this = (private_tester_t*) tester;
pthread_mutex_destroy(&(this->mutex)); pthread_mutex_destroy(&(this->mutex));
pfree(this); allocator_free(this);
return SUCCESS; return SUCCESS;
} }
tester_t *tester_create(FILE *output, bool display_succeeded_asserts) tester_t *tester_create(FILE *output, bool display_succeeded_asserts)
{ {
private_tester_t *this = alloc_thing(private_tester_t, "private_tester_t"); private_tester_t *this = allocator_alloc_thing(private_tester_t, "private_tester_t");
this->public.destroy = destroy; this->public.destroy = destroy;
this->public.perform_tests = perform_tests; this->public.perform_tests = perform_tests;
+2 -2
View File
@@ -76,7 +76,7 @@ static void event_queue_insert_thread(event_queue_test_t * testinfos)
{ {
for (j = 0; j < testinfos->entries_per_time;j++) for (j = 0; j < testinfos->entries_per_time;j++)
{ {
int *value = alloc_thing(int, "value"); int *value = allocator_alloc_thing(int, "value");
*value = i; *value = i;
job = job_create(INCOMING_PACKET,value); job = job_create(INCOMING_PACKET,value);
time.tv_usec = 0; time.tv_usec = 0;
@@ -131,7 +131,7 @@ void test_event_queue(tester_t *tester)
gettimeofday(&current_time,NULL); gettimeofday(&current_time,NULL);
tester->assert_true(tester,((current_time.tv_sec - start_time.tv_sec) == i), "value of entry check"); tester->assert_true(tester,((current_time.tv_sec - start_time.tv_sec) == i), "value of entry check");
pfree(job->assigned_data); allocator_free(job->assigned_data);
tester->assert_true(tester,(job->destroy(job) == SUCCESS), "job destroy call check"); tester->assert_true(tester,(job->destroy(job) == SUCCESS), "job destroy call check");
} }
} }
+2 -2
View File
@@ -63,7 +63,7 @@ static void test_job_queue_sender(job_queue_test_t * testinfo)
int i; int i;
for (i = 0; i < testinfo->insert_item_count; i++) for (i = 0; i < testinfo->insert_item_count; i++)
{ {
int *value = alloc_thing(int,"int in test_job_queue_sender"); int *value = allocator_alloc_thing(int,"int in test_job_queue_sender");
*value = i; *value = i;
job_t *job = job_create(INCOMING_PACKET,value); job_t *job = job_create(INCOMING_PACKET,value);
testinfo->job_queue->add(testinfo->job_queue,job); testinfo->job_queue->add(testinfo->job_queue,job);
@@ -83,7 +83,7 @@ static void test_job_queue_receiver(job_queue_test_t * testinfo)
job_t *job; job_t *job;
testinfo->tester->assert_true(testinfo->tester,(testinfo->job_queue->get(testinfo->job_queue,&job) == SUCCESS), "get job call check"); testinfo->tester->assert_true(testinfo->tester,(testinfo->job_queue->get(testinfo->job_queue,&job) == SUCCESS), "get job call check");
testinfo->tester->assert_true(testinfo->tester,(job->type == INCOMING_PACKET), "job type check"); testinfo->tester->assert_true(testinfo->tester,(job->type == INCOMING_PACKET), "job type check");
pfree(job->assigned_data); allocator_free(job->assigned_data);
testinfo->tester->assert_true(testinfo->tester,(job->destroy(job) == SUCCESS), "job destroy call check"); testinfo->tester->assert_true(testinfo->tester,(job->destroy(job) == SUCCESS), "job destroy call check");
} }
} }
+1 -1
View File
@@ -59,7 +59,7 @@ void test_receiver(tester_t *tester)
{ {
packet = packet_create(AF_INET); packet = packet_create(AF_INET);
packet->set_destination(packet,DESTINATION_IP,PORT_TO_SEND); packet->set_destination(packet,DESTINATION_IP,PORT_TO_SEND);
packet->data.ptr = alloc_thing(int, "packet data"); packet->data.ptr = allocator_alloc_thing(int, "packet data");
packet->data.len = ( sizeof(int)); packet->data.len = ( sizeof(int));
*((int *) (packet->data.ptr)) = i; *((int *) (packet->data.ptr)) = i;
global_socket->send(global_socket,packet); global_socket->send(global_socket,packet);
+1 -1
View File
@@ -57,7 +57,7 @@ void test_sender(tester_t *tester)
{ {
packet = packet_create(AF_INET); packet = packet_create(AF_INET);
packet->set_destination(packet,DESTINATION_IP,PORT_TO_SEND); packet->set_destination(packet,DESTINATION_IP,PORT_TO_SEND);
packet->data.ptr = alloc_thing(int, "packet data"); packet->data.ptr = allocator_alloc_thing(int, "packet data");
packet->data.len = ( sizeof(int)); packet->data.len = ( sizeof(int));
*((int *) (packet->data.ptr)) = i; *((int *) (packet->data.ptr)) = i;
global_send_queue->add(global_send_queue,packet); global_send_queue->add(global_send_queue,packet);
+1 -1
View File
@@ -39,7 +39,7 @@ void test_socket(tester_t *tester)
char *test_string = "Testing functionality of socket_t"; char *test_string = "Testing functionality of socket_t";
pkt->data.ptr = alloc_bytes(strlen(test_string) + 1,"test_string"); pkt->data.ptr = allocator_alloc(strlen(test_string) + 1,"test_string");
memcpy(pkt->data.ptr,test_string,strlen(test_string) + 1); memcpy(pkt->data.ptr,test_string,strlen(test_string) + 1);
pkt->data.len = strlen(test_string) + 1; pkt->data.len = strlen(test_string) + 1;