C: taxonomy: fixed a bug where some taxa would not be stored in the

merged index
This commit is contained in:
MercierC
2021-03-29 09:02:18 +13:00
parent 3e93cfff7b
commit f5413381fd
2 changed files with 27 additions and 1 deletions

View File

@ -2463,6 +2463,32 @@ int read_merged_dmp(const char* taxdump, OBIDMS_taxonomy_p tax, int32_t* delnode
return -1;
}
// Write the rest of the taxa from the current taxa list
while (nT < (tax->taxa)->count)
{
// Add element from taxa list
// Enlarge structure if needed
if (n == buffer_size)
{
buffer_size = buffer_size * 2;
tax->merged_idx = (ecomergedidx_t*) realloc(tax->merged_idx, sizeof(ecomergedidx_t) + sizeof(ecomerged_t) * buffer_size);
if (tax->merged_idx == NULL)
{
obi_set_errno(OBI_MALLOC_ERROR);
obidebug(1, "\nError reallocating memory for a taxonomy structure");
closedir(tax_dir);
fclose(file);
return -1;
}
}
(tax->merged_idx)->merged[n].taxid = (tax->taxa)->taxon[nT].taxid;
(tax->merged_idx)->merged[n].idx = nT;
nT++;
n++;
}
// Store count
(tax->merged_idx)->count = n;

View File

@ -75,7 +75,7 @@ typedef struct {
*/
int32_t max_taxid; /**< Maximum taxid existing in the taxon index.
*/
int32_t buffer_size; /**< Number of taxa. // TODO kept this but not sure of its use
int32_t buffer_size; /**< . // TODO kept this but not sure of its use
*/
ecotx_t taxon[]; /**< Taxon array.
*/