Commit 6bd42132 by Celine Mercier

Minor fixes to silence warnings and replaced two asprintf uses

parent 40859043
......@@ -61,7 +61,7 @@ static int bloom_check_add(struct bloom * bloom,
register unsigned int a = murmurhash2(buffer, len, 0x9747b28c);
register unsigned int b = murmurhash2(buffer, len, a);
register unsigned int x;
register unsigned int i;
register int i; // TODO why was it unsigned?
unsigned bucket_index = (a % bloom->buckets);
......
......@@ -28,9 +28,9 @@
bool only_ATGC(char* seq)
bool only_ATGC(const char* seq)
{
char* c = seq;
const char* c = seq;
while (*c)
{
......
......@@ -69,7 +69,7 @@ enum
* @since November 2015
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
bool only_ATGC(char* seq);
bool only_ATGC(const char* seq);
/**
......
......@@ -483,26 +483,9 @@ int grow_avl(OBIDMS_avl_p avl) // TODO Lock when needed
size_t new_data_size;
size_t header_size;
int avl_file_descriptor;
char* avl_file_name;
avl_file_descriptor = avl->avl_fd;
// // Get the avl file name
// avl_file_name = build_avl_file_name((avl->header)->avl_name);
// if (avl_file_name == NULL)
// return -1;
//
// // Open the avl file
// avl_file_descriptor = openat(avl->dir_fd, avl_file_name, O_RDWR);
// if (avl_file_descriptor < 0)
// {
// obi_set_errno(OBI_AVL_ERROR);
// obidebug(1, "\nError opening an AVL tree file");
// free(avl_file_name);
// return -1;
// }
// free(avl_file_name);
// Calculate the new file size
old_data_size = (avl->header)->avl_size;
new_data_size = old_data_size * AVL_GROWTH_FACTOR;
......@@ -563,26 +546,9 @@ int grow_avl_data(OBIDMS_avl_p avl) // TODO Lock when needed
index_t new_data_size;
size_t header_size;
int avl_data_file_descriptor;
char* avl_data_file_name;
avl_data_file_descriptor = avl->data_fd;
// // Get the avl data file name
// avl_data_file_name = build_avl_data_file_name((avl->header)->avl_name);
// if (avl_data_file_name == NULL)
// return -1;
//
// // Open the avl data file
// avl_data_file_descriptor = openat(avl->dir_fd, avl_data_file_name, O_RDWR);
// if (avl_data_file_descriptor < 0)
// {
// obi_set_errno(OBI_AVL_ERROR);
// obidebug(1, "\nError opening an AVL tree data file");
// free(avl_data_file_name);
// return -1;
// }
// free(avl_data_file_name);
// Calculate the new file size
old_data_size = ((avl->data)->header)->data_size_max;
new_data_size = old_data_size * AVL_GROWTH_FACTOR;
......@@ -1014,8 +980,20 @@ OBIDMS_avl_group_p obi_create_avl_group(OBIDMS_p dms, const char* avl_name)
avl_group = (OBIDMS_avl_group_p) malloc(sizeof(OBIDMS_avl_group_t));
// Create 1st avl
asprintf(&avl_name_with_idx,"%s_%u", avl_name, 0);
avl_name_with_idx = malloc((strlen(avl_name) + 3)*sizeof(char));
if (sprintf(avl_name_with_idx, "%s_%u", avl_name, 0) < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError building an AVL tree file name");
return NULL;
}
(avl_group->sub_avls)[0] = obi_create_avl(dms, avl_name_with_idx);
if ((avl_group->sub_avls)[0] == NULL)
{
obidebug(1, "\nError creating the first AVL of an AVL group");
return NULL;
}
avl_group->current_avl_idx = 0;
strcpy(avl_group->avl_name, avl_name);
......@@ -1039,7 +1017,7 @@ int remap_an_avl(OBIDMS_avl_p avl)
{
(avl->data)->data = mmap(NULL,
((avl->data)->header)->data_size_max,
PROT_READ | PROT_WRITE,
PROT_READ,
MAP_SHARED,
avl->data_fd,
((avl->data)->header)->header_size);
......@@ -1048,7 +1026,7 @@ int remap_an_avl(OBIDMS_avl_p avl)
avl->tree = mmap(NULL,
((avl->header)->nb_items_max) * sizeof(AVL_node_t),
PROT_READ | PROT_WRITE,
PROT_READ,
MAP_SHARED,
avl->avl_fd,
(avl->header)->header_size);
......@@ -1062,13 +1040,28 @@ int remap_an_avl(OBIDMS_avl_p avl)
int obi_add_new_avl_in_group(OBIDMS_avl_group_p avl_group) // TODO check for errors
{
char* avl_name_with_idx;
int avl_idx_length;
// unmap older
unmap_an_avl((avl_group->sub_avls)[avl_group->current_avl_idx]);
(avl_group->current_avl_idx)++;
asprintf(&avl_name_with_idx,"%s_%u", avl_group->avl_name, avl_group->current_avl_idx);
avl_idx_length = ((avl_group->current_avl_idx) == 0 ? 1 : (int)(log10(avl_group->current_avl_idx)+1));
avl_name_with_idx = malloc((strlen(avl_group->avl_name) + avl_idx_length + 2)*sizeof(char));
if (sprintf(avl_name_with_idx, "%s_%u", avl_group->avl_name, avl_group->current_avl_idx) < 0)
{
obi_set_errno(OBI_AVL_ERROR);
obidebug(1, "\nError building an AVL tree file name");
return -1;
}
//fprintf(stderr, "\nindex length = %d, file name = %s\n", avl_idx_length, avl_name_with_idx);
(avl_group->sub_avls)[avl_group->current_avl_idx] = obi_create_avl(avl_group->dms, avl_name_with_idx);
if ((avl_group->sub_avls)[avl_group->current_avl_idx] == NULL)
{
obidebug(1, "\nError creating a new AVL tree in a group");
return -1;
}
return 0;
}
......
......@@ -228,7 +228,6 @@ Obiview_p obi_new_view_nuc_seqs(OBIDMS_p dms, const char* view_name, Obiview_p v
if (view== NULL)
return NULL;
fprintf(stderr, "\nmmmm\n");
strcpy(view->view_type, VIEW_TYPE_NUC_SEQS);
if (view_to_clone == NULL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment