Commit 31726407 authored by Celine Mercier's avatar Celine Mercier

Taxonomy: fixed a bug where a pointer was not properly reallocated, and

a bug where the merged list of taxids was not built correctly
parent d21f4a6f
......@@ -2210,7 +2210,7 @@ int read_delnodes_dmp(const char* taxdump, OBIDMS_taxonomy_p tax, int32_t** deln
if (n == buffer_size)
{
buffer_size = buffer_size * 2;
(*delnodes_p) = (int32_t*) realloc(tax->merged_idx, sizeof(int32_t) * buffer_size);
(*delnodes_p) = (int32_t*) realloc(*delnodes_p, sizeof(int32_t) * buffer_size);
if ((*delnodes_p) == NULL)
{
obi_set_errno(OBI_MALLOC_ERROR);
......@@ -2378,7 +2378,7 @@ int read_merged_dmp(const char* taxdump, OBIDMS_taxonomy_p tax, int32_t* delnode
// and the deleted taxids with no current reference. An element of the list is composed of the taxid, and the index
// of the taxon in the taxa structure, or -1 for deleted taxids.
// Creating the merged list requires to merge the 3 ordered lists into one.
while (((nT < (tax->taxa)->count) && ((tax->taxa)->taxon[nT].taxid < old_taxid)) && ((nD >= 0) && (delnodes[nD] < old_taxid)))
while (((nT < (tax->taxa)->count) && ((tax->taxa)->taxon[nT].taxid < old_taxid)) || ((nD >= 0) && (delnodes[nD] < old_taxid)))
{
if ((tax->taxa)->taxon[nT].taxid < delnodes[nD])
{ // Add element from taxa list
......@@ -2399,6 +2399,7 @@ int read_merged_dmp(const char* taxdump, OBIDMS_taxonomy_p tax, int32_t* delnode
(tax->merged_idx)->merged[n].taxid = (tax->taxa)->taxon[nT].taxid;
(tax->merged_idx)->merged[n].idx = nT;
nT++;
n++;
}
......@@ -2421,6 +2422,7 @@ int read_merged_dmp(const char* taxdump, OBIDMS_taxonomy_p tax, int32_t* delnode
(tax->merged_idx)->merged[n].taxid = delnodes[nD];
(tax->merged_idx)->merged[n].idx = -1; // The index to tag deleted taxids is -1
nD--;
n++;
}
......@@ -2448,6 +2450,7 @@ int read_merged_dmp(const char* taxdump, OBIDMS_taxonomy_p tax, int32_t* delnode
// Store the old taxid with the index
(tax->merged_idx)->merged[n].taxid = old_taxid;
(tax->merged_idx)->merged[n].idx = t->idx;
n++;
}
......
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