Fixed more typos and formatting imperfections.

This commit is contained in:
Celine Mercier
2015-12-11 17:37:25 +01:00
parent a6144eabe2
commit cfaf069095

View File

@ -221,7 +221,7 @@ AVL_node_p avl_create_node(OBIDMS_avl_p avl, index_t node_idx);
* @brief Internal function updating the balance factors in an AVL tree
* after adding a node, only in the subtree that will have to be balanced.
* That subtree is found using the avl->path_idx array and the directions taken
* down the tree to add the new node are stored in the path->dir array.
* down the tree to add the new node are stored in the avl->path_dir array.
*
* @param avl A pointer to the AVL tree structure.
*
@ -357,7 +357,7 @@ static char* build_avl_file_name(const char* avl_name)
if (asprintf(&file_name,"%s.oda", avl_name) < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError building an avl file name");
obidebug(1, "\nError building an AVL tree file name");
return NULL;
}
@ -365,7 +365,7 @@ static char* build_avl_file_name(const char* avl_name)
if (strlen(file_name) >= AVL_MAX_NAME)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError due to avl name too long");
obidebug(1, "\nError due to AVL tree name too long");
free(file_name);
return NULL;
}
@ -382,7 +382,7 @@ static char* build_avl_data_file_name(const char* avl_name)
if (asprintf(&file_name,"%s.odd", avl_name) < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError building an avl data file name");
obidebug(1, "\nError building an AVL tree data file name");
return NULL;
}
@ -441,14 +441,14 @@ int close_avl_data(OBIDMS_avl_data_p avl_data)
if (munmap(avl_data->data, (avl_data->header)->data_size_max) < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError munmapping the data of an avl data file");
obidebug(1, "\nError munmapping the data of an AVL tree data file");
ret_val = -1;
}
if (munmap(avl_data->header, (avl_data->header)->header_size) < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError munmapping the header of an avl data file");
obidebug(1, "\nError munmapping the header of an AVL tree data file");
ret_val = -1;
}
@ -477,7 +477,7 @@ int grow_avl(OBIDMS_avl_p avl) // TODO Lock when needed
if (avl_file_descriptor < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError opening an avl file");
obidebug(1, "\nError opening an AVL tree file");
free(avl_file_name);
return -1;
}
@ -493,7 +493,7 @@ int grow_avl(OBIDMS_avl_p avl) // TODO Lock when needed
if (ftruncate(avl_file_descriptor, file_size) < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError enlarging an avl file");
obidebug(1, "\nError enlarging an AVL tree file");
close(avl_file_descriptor);
return -1;
}
@ -503,23 +503,23 @@ int grow_avl(OBIDMS_avl_p avl) // TODO Lock when needed
if (munmap(avl->tree, old_data_size) < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError munmapping the tree of an avl file before enlarging");
obidebug(1, "\nError munmapping the tree of an AVL tree file before enlarging");
close(avl_file_descriptor);
return -1;
}
avl->tree = mmap(NULL,
new_data_size,
PROT_READ | PROT_WRITE,
MAP_SHARED,
avl_file_descriptor,
header_size
);
new_data_size,
PROT_READ | PROT_WRITE,
MAP_SHARED,
avl_file_descriptor,
header_size
);
if (avl->tree == MAP_FAILED)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError re-mmapping the tree of an avl file after enlarging the file");
obidebug(1, "\nError re-mmapping the tree of an AVL tree file after enlarging the file");
close(avl_file_descriptor);
return -1;
}
@ -555,7 +555,7 @@ int grow_avl_data(OBIDMS_avl_p avl) // TODO Lock when needed
if (avl_data_file_descriptor < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError opening an avl data file");
obidebug(1, "\nError opening an AVL tree data file");
free(avl_data_file_name);
return -1;
}
@ -571,7 +571,7 @@ int grow_avl_data(OBIDMS_avl_p avl) // TODO Lock when needed
if (ftruncate(avl_data_file_descriptor, file_size) < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError enlarging an avl data file");
obidebug(1, "\nError enlarging an AVL tree data file");
close(avl_data_file_descriptor);
return -1;
}
@ -581,7 +581,7 @@ int grow_avl_data(OBIDMS_avl_p avl) // TODO Lock when needed
if (munmap((avl->data)->data, old_data_size) < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError munmapping the data of an avl data file before enlarging");
obidebug(1, "\nError munmapping the data of an AVL tree data file before enlarging");
close(avl_data_file_descriptor);
return -1;
}
@ -597,7 +597,7 @@ int grow_avl_data(OBIDMS_avl_p avl) // TODO Lock when needed
if ((avl->data)->data == MAP_FAILED)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError re-mmapping the data of an avl data file after enlarging the file");
obidebug(1, "\nError re-mmapping the data of an AVL tree data file after enlarging the file");
close(avl_data_file_descriptor);
return -1;
}
@ -927,21 +927,21 @@ void avl_print(OBIDMS_avl_p avl)
int obi_avl_exists(OBIDMS_p dms, const char* avl_name)
{
struct stat buffer;
char* avl_file_path;
char* avl_file_name;
int check_dir;
struct stat buffer;
char* avl_file_path;
char* avl_file_name;
int check_dir;
// Build file name
avl_file_name = build_avl_file_name(avl_name);
if (avl_file_name == NULL)
return -1;
// Build the avl file path
// Build the AVL tree file path
avl_file_path = get_full_path(dms->avl_dir_fd, avl_file_name);
if (avl_file_path == NULL)
{
obidebug(1, "\nError getting the file path for an avl file");
obidebug(1, "\nError getting the file path for an AVL tree file");
return -1;
}
@ -971,7 +971,7 @@ OBIDMS_avl_p obi_avl(OBIDMS_p dms, const char* avl_name)
return obi_open_avl(dms, avl_name);
};
obidebug(1, "\nError checking if an avl already exists");
obidebug(1, "\nError checking if an AVL tree already exists");
return NULL;
}
@ -1004,7 +1004,7 @@ OBIDMS_avl_p obi_create_avl(OBIDMS_p dms, const char* avl_name)
if (avl_data_file_descriptor < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError creating an avl data file");
obidebug(1, "\nError creating an AVL tree data file");
free(avl_data_file_name);
return NULL;
}
@ -1015,26 +1015,26 @@ OBIDMS_avl_p obi_create_avl(OBIDMS_p dms, const char* avl_name)
data_size = get_initial_avl_data_size();
file_size = header_size + data_size;
// Truncate the avl data file to the right size
// Truncate the AVL tree data file to the right size
if (ftruncate(avl_data_file_descriptor, file_size) < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError truncating an avl data file to the right size");
obidebug(1, "\nError truncating an AVL tree data file to the right size");
close(avl_data_file_descriptor);
return NULL;
}
// Allocate the memory for the avl data structure
// Allocate the memory for the AVL tree data structure
avl_data = (OBIDMS_avl_data_p) malloc(sizeof(OBIDMS_avl_data_t));
if (avl_data == NULL)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError allocating the memory for the avl data structure");
obidebug(1, "\nError allocating the memory for the AVL tree data structure");
close(avl_data_file_descriptor);
return NULL;
}
// Fill the avl data structure
// Fill the AVL tree data structure
avl_data->header = mmap(NULL,
header_size,
PROT_READ | PROT_WRITE,
@ -1045,7 +1045,7 @@ OBIDMS_avl_p obi_create_avl(OBIDMS_p dms, const char* avl_name)
if (avl_data->header == MAP_FAILED)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError mmapping the header of an avl data file");
obidebug(1, "\nError mmapping the header of an AVL tree data file");
close(avl_data_file_descriptor);
free(avl_data);
return NULL;
@ -1061,7 +1061,7 @@ OBIDMS_avl_p obi_create_avl(OBIDMS_p dms, const char* avl_name)
if (avl_data->data == MAP_FAILED)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError mmapping the data of an avl data file");
obidebug(1, "\nError mmapping the data of an AVL tree data file");
munmap(avl_data->header, header_size);
close(avl_data_file_descriptor);
free(avl_data);
@ -1081,7 +1081,7 @@ OBIDMS_avl_p obi_create_avl(OBIDMS_p dms, const char* avl_name)
close(avl_data_file_descriptor);
// Create the avl file
// Create the AVL tree file
// Build file name
avl_file_name = build_avl_file_name(avl_name);
@ -1101,35 +1101,35 @@ OBIDMS_avl_p obi_create_avl(OBIDMS_p dms, const char* avl_name)
if (avl_file_descriptor < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError creating an avl file");
obidebug(1, "\nError creating an AVL tree file");
close_avl_data(avl_data);
free(avl_file_name);
return NULL;
}
free(avl_file_name);
// Truncate the avl file to the right size
// Truncate the AVL tree file to the right size
if (ftruncate(avl_file_descriptor, file_size) < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError truncating an avl file to the right size");
obidebug(1, "\nError truncating an AVL tree file to the right size");
close_avl_data(avl_data);
close(avl_file_descriptor);
return NULL;
}
// Allocate the memory for the avl structure
// Allocate the memory for the AVL tree structure
avl = (OBIDMS_avl_p) malloc(sizeof(OBIDMS_avl_t));
if (avl == NULL)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError allocating the memory for the avl structure");
obidebug(1, "\nError allocating the memory for the AVL tree structure");
close_avl_data(avl_data);
close(avl_file_descriptor);
return NULL;
}
// Fill the avl structure
// Fill the AVL tree structure
avl->header = mmap(NULL,
header_size,
PROT_READ | PROT_WRITE,
@ -1140,7 +1140,7 @@ OBIDMS_avl_p obi_create_avl(OBIDMS_p dms, const char* avl_name)
if (avl->header == MAP_FAILED)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError mmapping the header of an avl file");
obidebug(1, "\nError mmapping the header of an AVL tree file");
close_avl_data(avl_data);
close(avl_file_descriptor);
free(avl);
@ -1157,7 +1157,7 @@ OBIDMS_avl_p obi_create_avl(OBIDMS_p dms, const char* avl_name)
if (avl->tree == MAP_FAILED)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError mmapping the data of an avl file");
obidebug(1, "\nError mmapping the data of an AVL tree file");
close_avl_data(avl_data);
munmap(avl->header, header_size);
close(avl_file_descriptor);
@ -1180,7 +1180,7 @@ OBIDMS_avl_p obi_create_avl(OBIDMS_p dms, const char* avl_name)
close(avl_file_descriptor);
// Add in the list of opened avls
// Add in the list of opened AVL trees
*(((dms->opened_avls)->avls)+((dms->opened_avls)->nb_opened_avls)) = avl;
((dms->opened_avls)->nb_opened_avls)++;
avl->counter = 1;
@ -1201,11 +1201,11 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name)
OBIDMS_avl_p avl;
size_t i;
// Check if the avl is already in the list of opened avls
// Check if the AVL tree is already in the list of opened AVL trees
for (i=0; i < ((dms->opened_avls)->nb_opened_avls); i++)
{
if (!strcmp(((*(((dms->opened_avls)->avls)+i))->header)->avl_name, avl_name))
{ // Found the avl already opened
{ // Found the AVL tree already opened
((*(((dms->opened_avls)->avls)+i))->counter)++;
return *(((dms->opened_avls)->avls)+i);
}
@ -1213,7 +1213,7 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name)
// Open the data file
// Get the file descriptor of the avl directory
// Get the file descriptor of the AVL trees directory
avl_dir_file_descriptor = dms->avl_dir_fd;
// Build file name
@ -1226,18 +1226,18 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name)
if (avl_data_file_descriptor < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError opening an avl data file");
obidebug(1, "\nError opening an AVL tree data file");
free(avl_data_file_name);
return NULL;
}
free(avl_data_file_name);
// Allocate the memory for the avl data structure
// Allocate the memory for the AVL tree data structure
avl_data = (OBIDMS_avl_data_p) malloc(sizeof(OBIDMS_avl_data_t));
if (avl_data == NULL)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError allocating the memory for the avl data structure");
obidebug(1, "\nError allocating the memory for the AVL tree data structure");
close(avl_data_file_descriptor);
return NULL;
}
@ -1246,7 +1246,7 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name)
if (read(avl_data_file_descriptor, &header_size, sizeof(size_t)) < ((ssize_t) sizeof(size_t)))
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError reading the header size to open a data avl");
obidebug(1, "\nError reading the header size to open an AVL tree data file");
close(avl_data_file_descriptor);
return NULL;
}
@ -1262,7 +1262,7 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name)
if (avl_data->header == MAP_FAILED)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError mmapping the header of an avl data file");
obidebug(1, "\nError mmapping the header of an AVL tree data file");
close(avl_data_file_descriptor);
free(avl_data);
return NULL;
@ -1278,7 +1278,7 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name)
if (avl_data->data == MAP_FAILED)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError mmapping the data of an avl data file");
obidebug(1, "\nError mmapping the data of an AVL tree data file");
munmap(avl_data->header, header_size);
close(avl_data_file_descriptor);
free(avl_data);
@ -1288,7 +1288,7 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name)
close(avl_data_file_descriptor);
// Open the avl file
// Open the AVL tree file
// Build file name
avl_file_name = build_avl_file_name(avl_name);
@ -1303,19 +1303,19 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name)
if (avl_file_descriptor < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError opening an avl file");
obidebug(1, "\nError opening an AVL tree file");
close_avl_data(avl_data);
free(avl_file_name);
return NULL;
}
free(avl_file_name);
// Allocate the memory for the avl structure
// Allocate the memory for the AVL tree structure
avl = (OBIDMS_avl_p) malloc(sizeof(OBIDMS_avl_t));
if (avl == NULL)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError allocating the memory for the avl structure");
obidebug(1, "\nError allocating the memory for the AVL tree structure");
close_avl_data(avl_data);
close(avl_file_descriptor);
return NULL;
@ -1325,7 +1325,7 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name)
if (read(avl_file_descriptor, &header_size, sizeof(size_t)) < ((ssize_t) sizeof(size_t)))
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError reading the header size to open an avl");
obidebug(1, "\nError reading the header size to open an AVL tree");
close(avl_file_descriptor);
return NULL;
}
@ -1341,7 +1341,7 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name)
if (avl->header == MAP_FAILED)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError mmapping the header of an avl file");
obidebug(1, "\nError mmapping the header of an AVL tree file");
close_avl_data(avl_data);
close(avl_file_descriptor);
free(avl);
@ -1358,7 +1358,7 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name)
if (avl->tree == MAP_FAILED)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError mmapping the data of an avl file");
obidebug(1, "\nError mmapping the data of an AVL tree file");
close_avl_data(avl_data);
munmap(avl->header, header_size);
close(avl_file_descriptor);
@ -1373,7 +1373,7 @@ OBIDMS_avl_p obi_open_avl(OBIDMS_p dms, const char* avl_name)
close(avl_file_descriptor);
// Add in the list of opened avls
// Add in the list of opened AVL trees
*(((dms->opened_avls)->avls)+((dms->opened_avls)->nb_opened_avls)) = avl;
((dms->opened_avls)->nb_opened_avls)++;
avl->counter = 1;
@ -1412,14 +1412,14 @@ int obi_close_avl(OBIDMS_avl_p avl)
if (munmap(avl->tree, (((avl->header)->nb_items_max) * sizeof(AVL_node_t))) < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError munmapping the avl of an avl file");
obidebug(1, "\nError munmapping the tree of an AVL tree file");
ret_val = -1;
}
if (munmap(avl->header, (avl->header)->header_size) < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError munmapping the header of an avl file");
obidebug(1, "\nError munmapping the header of an AVL tree file");
ret_val = -1;
}