diff options
author | Jan Hutter <jhutter@hsr.ch> | 2005-11-09 09:35:06 +0000 |
---|---|---|
committer | Jan Hutter <jhutter@hsr.ch> | 2005-11-09 09:35:06 +0000 |
commit | 6c4b815f22341ad3c2574b42a64b39e16ef1e7c7 (patch) | |
tree | 57c322fecce2b837b34654758a0e394ffdfaa90e | |
parent | 79538669625bbae26fcef5d791b2246242c5a407 (diff) | |
download | strongswan-6c4b815f22341ad3c2574b42a64b39e16ef1e7c7.tar.bz2 strongswan-6c4b815f22341ad3c2574b42a64b39e16ef1e7c7.tar.xz |
- memory allocation now works with allocator-functions...
-rw-r--r-- | Source/charon/configuration.c | 3 | ||||
-rw-r--r-- | Source/charon/event_queue.c | 6 | ||||
-rw-r--r-- | Source/charon/generator.c | 5 | ||||
-rw-r--r-- | Source/charon/ike_sa.c | 3 | ||||
-rw-r--r-- | Source/charon/ike_sa_id.c | 3 | ||||
-rw-r--r-- | Source/charon/ike_sa_manager.c | 5 | ||||
-rw-r--r-- | Source/charon/job.c | 3 | ||||
-rw-r--r-- | Source/charon/job_queue.c | 3 | ||||
-rw-r--r-- | Source/charon/linked_list.c | 7 | ||||
-rw-r--r-- | Source/charon/message.c | 3 | ||||
-rw-r--r-- | Source/charon/packet.c | 3 | ||||
-rw-r--r-- | Source/charon/receiver.c | 3 | ||||
-rw-r--r-- | Source/charon/scheduler.c | 3 | ||||
-rw-r--r-- | Source/charon/send_queue.c | 3 | ||||
-rw-r--r-- | Source/charon/sender.c | 3 | ||||
-rw-r--r-- | Source/charon/socket.c | 8 | ||||
-rw-r--r-- | Source/charon/tester.c | 3 | ||||
-rw-r--r-- | Source/charon/tests.c | 9 | ||||
-rw-r--r-- | Source/charon/tests/event_queue_test.c | 3 | ||||
-rw-r--r-- | Source/charon/tests/job_queue_test.c | 3 | ||||
-rw-r--r-- | Source/charon/tests/receiver_test.c | 3 | ||||
-rw-r--r-- | Source/charon/tests/scheduler_test.c | 1 | ||||
-rw-r--r-- | Source/charon/tests/sender_test.c | 3 | ||||
-rw-r--r-- | Source/charon/tests/socket_test.c | 3 | ||||
-rw-r--r-- | Source/charon/tests/thread_pool_test.c | 2 |
25 files changed, 57 insertions, 37 deletions
diff --git a/Source/charon/configuration.c b/Source/charon/configuration.c index 0cb9d6705..244fe86bd 100644 --- a/Source/charon/configuration.c +++ b/Source/charon/configuration.c @@ -26,6 +26,7 @@ #include <pluto/constants.h> #include <pluto/defs.h> +#include "allocator.h" #include "types.h" #include "configuration.h" @@ -64,7 +65,7 @@ static status_t destroy (private_configuration_t *this) */ configuration_t * configuration_create() { - private_configuration_t *this = allocator_alloc_thing(private_configuration_t, "private_configuration_t"); + private_configuration_t *this = allocator_alloc_thing(private_configuration_t); if (this == NULL) { return NULL; diff --git a/Source/charon/event_queue.c b/Source/charon/event_queue.c index d086bf44f..a4dd5980d 100644 --- a/Source/charon/event_queue.c +++ b/Source/charon/event_queue.c @@ -26,7 +26,7 @@ #include <pthread.h> #include <stdlib.h> - +#include "allocator.h" #include "types.h" #include "event_queue.h" #include "linked_list.h" @@ -85,7 +85,7 @@ static status_t event_destroy(event_t *event) */ static event_t *event_create(timeval_t time, job_t *job) { - event_t *this = allocator_alloc_thing(event_t, "event_t"); + event_t *this = allocator_alloc_thing(event_t); this->destroy = event_destroy; @@ -361,7 +361,7 @@ event_queue_t *event_queue_create() return NULL; } - private_event_queue_t *this = allocator_alloc_thing(private_event_queue_t, "private_event_queue_t"); + private_event_queue_t *this = allocator_alloc_thing(private_event_queue_t); if (this == NULL) { linked_list->destroy(linked_list); diff --git a/Source/charon/generator.c b/Source/charon/generator.c index dd7b1e58e..c06cba6ac 100644 --- a/Source/charon/generator.c +++ b/Source/charon/generator.c @@ -25,6 +25,7 @@ #include <pluto/constants.h> #include <pluto/defs.h> +#include "allocator.h" #include "types.h" #include "generator.h" @@ -106,7 +107,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) { - u_int8_t * buffer = allocator_alloc(GENERATOR_DATA_BUFFER_SIZE, "generator buffer"); + u_int8_t * buffer = allocator_alloc(GENERATOR_DATA_BUFFER_SIZE); u_int8_t * out_position = buffer; u_int8_t * roof_position = buffer + GENERATOR_DATA_BUFFER_SIZE; size_t current_bit = 0; @@ -188,7 +189,7 @@ generator_t * generator_create(payload_info_t ** payload_infos) return NULL; } - this = allocator_alloc_thing(private_generator_t,"private_generator_t"); + this = allocator_alloc_thing(private_generator_t); if (this == NULL) { return NULL; diff --git a/Source/charon/ike_sa.c b/Source/charon/ike_sa.c index f5333c638..638b64d12 100644 --- a/Source/charon/ike_sa.c +++ b/Source/charon/ike_sa.c @@ -21,6 +21,7 @@ * for more details. */ +#include "allocator.h" #include "types.h" #include "linked_list.h" #include "ike_sa.h" @@ -145,7 +146,7 @@ static status_t destroy (private_ike_sa_t *this) */ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id) { - private_ike_sa_t *this = allocator_alloc_thing(private_ike_sa_t, "private_ike_sa_t"); + private_ike_sa_t *this = allocator_alloc_thing(private_ike_sa_t); if (this == NULL) { return NULL; diff --git a/Source/charon/ike_sa_id.c b/Source/charon/ike_sa_id.c index 8ff1fd75a..3634c829c 100644 --- a/Source/charon/ike_sa_id.c +++ b/Source/charon/ike_sa_id.c @@ -26,6 +26,7 @@ #include <pluto/constants.h> #include <pluto/defs.h> +#include "allocator.h" #include "types.h" #include "ike_sa_id.h" @@ -182,7 +183,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) { - private_ike_sa_id_t *this = allocator_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); if (this == NULL) { return NULL; diff --git a/Source/charon/ike_sa_manager.c b/Source/charon/ike_sa_manager.c index 19a7139b3..267e3b0da 100644 --- a/Source/charon/ike_sa_manager.c +++ b/Source/charon/ike_sa_manager.c @@ -23,6 +23,7 @@ #include <pthread.h> #include <string.h> +#include "allocator.h" #include "ike_sa_manager.h" #include "linked_list.h" #include "ike_sa_id.h" @@ -78,7 +79,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 *this = allocator_alloc_thing(ike_sa_entry_t, "ike_sa_entry_t"); + ike_sa_entry_t *this = allocator_alloc_thing(ike_sa_entry_t); this->destroy = ike_sa_entry_destroy; this->waiting_threads = 0; @@ -512,7 +513,7 @@ static status_t destroy(private_ike_sa_manager_t *this) ike_sa_manager_t *ike_sa_manager_create() { - private_ike_sa_manager_t *this = allocator_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); /* assign public functions */ this->public.destroy = (status_t(*)(ike_sa_manager_t*))destroy; diff --git a/Source/charon/job.c b/Source/charon/job.c index 4db37bec6..5332cc84e 100644 --- a/Source/charon/job.c +++ b/Source/charon/job.c @@ -25,6 +25,7 @@ #include <pluto/constants.h> #include <pluto/defs.h> +#include "allocator.h" #include "job.h" /** @@ -41,7 +42,7 @@ static status_t job_destroy(job_t *job) */ job_t *job_create(job_type_t type, void *assigned_data) { - job_t *this = allocator_alloc_thing(job_t, "job_t"); + job_t *this = allocator_alloc_thing(job_t); this->destroy = job_destroy; diff --git a/Source/charon/job_queue.c b/Source/charon/job_queue.c index 3c4d74ac2..b5c21e6b2 100644 --- a/Source/charon/job_queue.c +++ b/Source/charon/job_queue.c @@ -26,6 +26,7 @@ #include <pluto/constants.h> #include <pluto/defs.h> +#include "allocator.h" #include "job_queue.h" #include "linked_list.h" @@ -149,7 +150,7 @@ job_queue_t *job_queue_create() return NULL; } - private_job_queue_t *this = allocator_alloc_thing(private_job_queue_t, "private_job_queue_t"); + private_job_queue_t *this = allocator_alloc_thing(private_job_queue_t); if (this == NULL) { linked_list->destroy(linked_list); diff --git a/Source/charon/linked_list.c b/Source/charon/linked_list.c index 908178213..78a2f6612 100644 --- a/Source/charon/linked_list.c +++ b/Source/charon/linked_list.c @@ -25,6 +25,7 @@ #include <pluto/constants.h> #include <pluto/defs.h> +#include "allocator.h" #include "linked_list.h" @@ -87,7 +88,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 *this = allocator_alloc_thing(linked_list_element_t, "linked_list_element_t"); + linked_list_element_t *this = allocator_alloc_thing(linked_list_element_t); if (this == NULL) { @@ -252,7 +253,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) { - private_linked_list_iterator_t *this = allocator_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); if (this == NULL) { @@ -682,7 +683,7 @@ static status_t linked_list_destroy(private_linked_list_t *this) */ linked_list_t *linked_list_create() { - private_linked_list_t *this = allocator_alloc_thing(private_linked_list_t, "private_linked_list_t"); + private_linked_list_t *this = allocator_alloc_thing(private_linked_list_t); 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; diff --git a/Source/charon/message.c b/Source/charon/message.c index 90640042a..1651d9daf 100644 --- a/Source/charon/message.c +++ b/Source/charon/message.c @@ -25,6 +25,7 @@ #include <pluto/constants.h> #include <pluto/defs.h> +#include "allocator.h" #include "types.h" #include "message.h" @@ -63,7 +64,7 @@ static status_t destroy (private_message_t *this) */ message_t * message_create() { - private_message_t *this = allocator_alloc_thing(private_message_t, "private_message_t"); + private_message_t *this = allocator_alloc_thing(private_message_t); if (this == NULL) { return NULL; diff --git a/Source/charon/packet.c b/Source/charon/packet.c index 22977bd48..94b58e5e1 100644 --- a/Source/charon/packet.c +++ b/Source/charon/packet.c @@ -20,6 +20,7 @@ * for more details. */ +#include "allocator.h" #include "packet.h" @@ -68,7 +69,7 @@ status_t set_source(packet_t *this, char *address, u_int16_t port) packet_t *packet_create(int family) { - packet_t *this = allocator_alloc_thing(packet_t, "packet_t"); + packet_t *this = allocator_alloc_thing(packet_t); this->destroy = destroy; this->set_destination = set_destination; diff --git a/Source/charon/receiver.c b/Source/charon/receiver.c index 85576075a..abbb5cf8d 100644 --- a/Source/charon/receiver.c +++ b/Source/charon/receiver.c @@ -26,6 +26,7 @@ #include <pluto/constants.h> #include <pluto/defs.h> +#include "allocator.h" #include "receiver.h" #include "socket.h" #include "packet.h" @@ -105,7 +106,7 @@ static status_t destroy(private_receiver_t *this) receiver_t * receiver_create() { - private_receiver_t *this = allocator_alloc_thing(private_receiver_t,"private_receiver_t"); + private_receiver_t *this = allocator_alloc_thing(private_receiver_t); this->public.destroy = (status_t(*)(receiver_t*)) destroy; if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))receiver_thread_function, this) != 0) diff --git a/Source/charon/scheduler.c b/Source/charon/scheduler.c index 05d999b87..7a00bc88f 100644 --- a/Source/charon/scheduler.c +++ b/Source/charon/scheduler.c @@ -26,6 +26,7 @@ #include <pluto/constants.h> #include <pluto/defs.h> +#include "allocator.h" #include "scheduler.h" #include "job_queue.h" #include "globals.h" @@ -85,7 +86,7 @@ static status_t destroy(private_scheduler_t *this) scheduler_t * scheduler_create() { - private_scheduler_t *this = allocator_alloc_thing(private_scheduler_t,"private_scheduler_t"); + private_scheduler_t *this = allocator_alloc_thing(private_scheduler_t); this->public.destroy = (status_t(*)(scheduler_t*)) destroy; if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))scheduler_thread_function, this) != 0) diff --git a/Source/charon/send_queue.c b/Source/charon/send_queue.c index 673ba38f1..3cb61b06e 100644 --- a/Source/charon/send_queue.c +++ b/Source/charon/send_queue.c @@ -22,6 +22,7 @@ #include <pthread.h> +#include "allocator.h" #include "send_queue.h" #include "linked_list.h" @@ -149,7 +150,7 @@ send_queue_t *send_queue_create() return NULL; } - private_send_queue_t *this = allocator_alloc_thing(private_send_queue_t, "private_send_queue_t"); + private_send_queue_t *this = allocator_alloc_thing(private_send_queue_t); if (this == NULL) { linked_list->destroy(linked_list); diff --git a/Source/charon/sender.c b/Source/charon/sender.c index 5d821b2f5..20d301f5e 100644 --- a/Source/charon/sender.c +++ b/Source/charon/sender.c @@ -26,6 +26,7 @@ #include <pluto/constants.h> #include <pluto/defs.h> +#include "allocator.h" #include "sender.h" #include "socket.h" #include "packet.h" @@ -101,7 +102,7 @@ static status_t destroy(private_sender_t *this) sender_t * sender_create() { - private_sender_t *this = allocator_alloc_thing(private_sender_t,"private_sender_t"); + private_sender_t *this = allocator_alloc_thing(private_sender_t); this->public.destroy = (status_t(*)(sender_t*)) destroy; if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))sender_thread_function, this) != 0) diff --git a/Source/charon/socket.c b/Source/charon/socket.c index 782a349b2..5b6ad2f8c 100644 --- a/Source/charon/socket.c +++ b/Source/charon/socket.c @@ -22,8 +22,6 @@ * for more details. */ -#include "socket.h" - #include <pthread.h> #include <sys/types.h> #include <sys/socket.h> @@ -34,6 +32,8 @@ #include <pluto/constants.h> #include <pluto/defs.h> +#include "allocator.h" +#include "socket.h" typedef struct private_socket_s private_socket_t; @@ -83,7 +83,7 @@ status_t receiver(private_socket_t *this, packet_t **packet) } /* fill in packet */ - pkt->data.ptr = allocator_alloc(pkt->data.len, "data in packet_t"); + pkt->data.ptr = allocator_alloc(pkt->data.len); memcpy(pkt->data.ptr, buffer, pkt->data.len); /* return packet */ @@ -124,7 +124,7 @@ status_t destroy(private_socket_t *this) socket_t *socket_create(u_int16_t port) { - private_socket_t *this = allocator_alloc_thing(private_socket_t, "private_socket_t"); + private_socket_t *this = allocator_alloc_thing(private_socket_t); struct sockaddr_in addr; /* public functions */ diff --git a/Source/charon/tester.c b/Source/charon/tester.c index 4fe6410f6..96af2edd4 100644 --- a/Source/charon/tester.c +++ b/Source/charon/tester.c @@ -29,6 +29,7 @@ #include <pthread.h> #include <sys/time.h> +#include "allocator.h" #include "tester.h" #include "linked_list.h" #include "thread_pool.h" @@ -179,7 +180,7 @@ static status_t destroy(tester_t *tester) tester_t *tester_create(FILE *output, bool display_succeeded_asserts) { - private_tester_t *this = allocator_alloc_thing(private_tester_t, "private_tester_t"); + private_tester_t *this = allocator_alloc_thing(private_tester_t); this->public.destroy = destroy; this->public.perform_tests = perform_tests; diff --git a/Source/charon/tests.c b/Source/charon/tests.c index 47297dc09..565b2e15c 100644 --- a/Source/charon/tests.c +++ b/Source/charon/tests.c @@ -149,9 +149,9 @@ socket_t *global_socket; &job_queue_test1, &event_queue_test, &send_queue_test, + &scheduler_test, &socket_test, &sender_test, - &scheduler_test, &receiver_test, &ike_sa_id_test, &ike_sa_test, @@ -167,8 +167,8 @@ socket_t *global_socket; tester_t *tester = tester_create(test_output, FALSE); -/* tester->perform_tests(tester,all_tests); */ - tester->perform_test(tester,&thread_pool_test); + tester->perform_tests(tester,all_tests); +/* tester->perform_test(tester,&scheduler_test); */ tester->destroy(tester); @@ -180,8 +180,7 @@ socket_t *global_socket; global_socket->destroy(global_socket); #ifdef LEAK_DETECTIVE - /* Leaks are reported in log file */ - report_leaks(); + /* Leaks are reported on stderr */ report_memory_leaks(); #endif diff --git a/Source/charon/tests/event_queue_test.c b/Source/charon/tests/event_queue_test.c index de39653aa..28cdf25f4 100644 --- a/Source/charon/tests/event_queue_test.c +++ b/Source/charon/tests/event_queue_test.c @@ -23,6 +23,7 @@ #include <stdlib.h> #include <pthread.h> +#include "../allocator.h" #include "event_queue_test.h" #include "../tester.h" #include "../event_queue.h" @@ -76,7 +77,7 @@ static void event_queue_insert_thread(event_queue_test_t * testinfos) { for (j = 0; j < testinfos->entries_per_time;j++) { - int *value = allocator_alloc_thing(int, "value"); + int *value = allocator_alloc_thing(int); *value = i; job = job_create(INCOMING_PACKET,value); time.tv_usec = 0; diff --git a/Source/charon/tests/job_queue_test.c b/Source/charon/tests/job_queue_test.c index 5e1fa8121..b42512aa0 100644 --- a/Source/charon/tests/job_queue_test.c +++ b/Source/charon/tests/job_queue_test.c @@ -28,6 +28,7 @@ #include <pthread.h> #include <unistd.h> +#include "../allocator.h" #include "job_queue_test.h" #include "../tester.h" #include "../job_queue.h" @@ -63,7 +64,7 @@ static void test_job_queue_sender(job_queue_test_t * testinfo) int i; for (i = 0; i < testinfo->insert_item_count; i++) { - int *value = allocator_alloc_thing(int,"int in test_job_queue_sender"); + int *value = allocator_alloc_thing(int); *value = i; job_t *job = job_create(INCOMING_PACKET,value); testinfo->job_queue->add(testinfo->job_queue,job); diff --git a/Source/charon/tests/receiver_test.c b/Source/charon/tests/receiver_test.c index 59ab540b5..2c3556d16 100644 --- a/Source/charon/tests/receiver_test.c +++ b/Source/charon/tests/receiver_test.c @@ -23,6 +23,7 @@ #include <string.h> #include <unistd.h> +#include "../allocator.h" #include "sender_test.h" #include "../globals.h" #include "../receiver.h" @@ -59,7 +60,7 @@ void test_receiver(tester_t *tester) { packet = packet_create(AF_INET); packet->set_destination(packet,DESTINATION_IP,PORT_TO_SEND); - packet->data.ptr = allocator_alloc_thing(int, "packet data"); + packet->data.ptr = allocator_alloc_thing(int); packet->data.len = ( sizeof(int)); *((int *) (packet->data.ptr)) = i; global_socket->send(global_socket,packet); diff --git a/Source/charon/tests/scheduler_test.c b/Source/charon/tests/scheduler_test.c index b6cac6f37..ab89fe053 100644 --- a/Source/charon/tests/scheduler_test.c +++ b/Source/charon/tests/scheduler_test.c @@ -71,6 +71,7 @@ void test_scheduler(tester_t *tester) usleep(100 * 1000); global_event_queue->get_count(global_event_queue, &event_queue_size); global_job_queue->get_count(global_job_queue, &job_queue_size); + tester->assert_true(tester, (job_queue_size == current + 1), "job-queue size after event"); tester->assert_true(tester, (event_queue_size == job_count - current - 1), "event-queue size after event"); } diff --git a/Source/charon/tests/sender_test.c b/Source/charon/tests/sender_test.c index 3f8cfa8f4..56a5d9c31 100644 --- a/Source/charon/tests/sender_test.c +++ b/Source/charon/tests/sender_test.c @@ -22,6 +22,7 @@ #include <string.h> +#include "../allocator.h" #include "sender_test.h" #include "../globals.h" #include "../sender.h" @@ -57,7 +58,7 @@ void test_sender(tester_t *tester) { packet = packet_create(AF_INET); packet->set_destination(packet,DESTINATION_IP,PORT_TO_SEND); - packet->data.ptr = allocator_alloc_thing(int, "packet data"); + packet->data.ptr = allocator_alloc_thing(int); packet->data.len = ( sizeof(int)); *((int *) (packet->data.ptr)) = i; global_send_queue->add(global_send_queue,packet); diff --git a/Source/charon/tests/socket_test.c b/Source/charon/tests/socket_test.c index ea61e5f3c..127390394 100644 --- a/Source/charon/tests/socket_test.c +++ b/Source/charon/tests/socket_test.c @@ -23,6 +23,7 @@ #include <stdlib.h> #include <string.h> +#include "../allocator.h" #include "socket_test.h" #include "../tester.h" #include "../socket.h" @@ -39,7 +40,7 @@ void test_socket(tester_t *tester) char *test_string = "Testing functionality of socket_t"; - pkt->data.ptr = allocator_alloc(strlen(test_string) + 1,"test_string"); + pkt->data.ptr = allocator_alloc(strlen(test_string) + 1); memcpy(pkt->data.ptr,test_string,strlen(test_string) + 1); pkt->data.len = strlen(test_string) + 1; diff --git a/Source/charon/tests/thread_pool_test.c b/Source/charon/tests/thread_pool_test.c index de2e51d2b..1e8ac4646 100644 --- a/Source/charon/tests/thread_pool_test.c +++ b/Source/charon/tests/thread_pool_test.c @@ -37,5 +37,5 @@ void test_thread_pool(tester_t *tester) thread_pool_t *pool = thread_pool_create(desired_pool_size); pool->get_pool_size(pool, &pool_size); tester->assert_true(tester, (desired_pool_size == pool_size), "thread creation"); - //tester->assert_true(tester, (pool->destroy(pool) == SUCCESS), "threadpool destruction"); + tester->assert_true(tester, (pool->destroy(pool) == SUCCESS), "threadpool destruction"); } |