- 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
+24 -24
View File
@@ -1,8 +1,8 @@
/**
* @file generator.c
*
*
* @brief Generic generator class used to generate IKEv2-Header and Payload
*
*
*/
/*
@@ -32,18 +32,18 @@
* Private data of a generator_t object
*/
typedef struct private_generator_s private_generator_t;
struct private_generator_s {
struct private_generator_s {
/**
* Public part of a generator object
*/
generator_t public;
/* private functions and fields */
/**
* Generates a chunk_t with specific encoding rules
*
*
* items are bytewhise written
*
* @param this private_generator_t-object
@@ -51,17 +51,17 @@ struct private_generator_s {
* @param encoding_rules pointer to first encoding_rule of encoding rules array
* @param encoding_rules_count number of encoding rules in encoding rules array
* @param data pointer to chunk where to write the data in
*
*
* @return SUCCESS if succeeded,
* OUT_OF_RES if out of ressources
*/
status_t (*generate) (private_generator_t *this,void * data_struct,encoding_rule_t *encoding_rules, size_t encoding_rules_count, chunk_t *data);
/**
* TODO
*/
status_t (*generate_u_int_type) (private_generator_t *this,encoding_type_t int_type,u_int8_t **buffer,u_int8_t **out_position,u_int8_t **roof_position,size_t *current_bit);
/**
* Pointer to the payload informations needed to automatic
* generate a specific payload type
@@ -76,8 +76,8 @@ struct private_generator_s {
static status_t generate_u_int_type (private_generator_t *this,encoding_type_t int_type,u_int8_t **buffer,u_int8_t **out_position,u_int8_t **roof_position,size_t *current_bit)
{
size_t number_of_bits = 0;
size_t number_of_bits = 0;
switch (int_type)
{
case U_INT_4:
@@ -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)
{
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 * roof_position = buffer + GENERATOR_DATA_BUFFER_SIZE;
size_t current_bit = 0;
@@ -138,18 +138,18 @@ static status_t generate (private_generator_t *this,void * data_struct,encoding_
}
if (status != SUCCESS)
{
pfree(buffer);
allocator_free(buffer);
return status;
}
}
return SUCCESS;
}
static status_t generate_payload (private_generator_t *this,payload_type_t payload_type,void * data_struct, chunk_t *data)
{
int i;
/* check every payload info for specific type */
for (i = 0; this->payload_infos[i] != NULL; i++)
{
@@ -172,7 +172,7 @@ static status_t destroy(private_generator_t *this)
return FAILED;
}
pfree(this);
allocator_free(this);
return SUCCESS;
}
@@ -182,26 +182,26 @@ static status_t destroy(private_generator_t *this)
generator_t * generator_create(payload_info_t ** payload_infos)
{
private_generator_t *this;
if (payload_infos == 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)
{
return NULL;
}
this->public.generate_payload = (status_t(*)(generator_t*, payload_type_t, void *, chunk_t *)) generate_payload;
this->public.destroy = (status_t(*)(generator_t*)) destroy;
/* initiate private fields */
this->generate = generate;
this->generate_u_int_type = generate_u_int_type;
this->payload_infos = payload_infos;
return &(this->public);
}