Actualiser src/libecoPCR/ecorank.c
This commit is contained in:
@ -12,14 +12,14 @@ ecorankidx_t *read_rankidx(const char *filename)
|
|||||||
int32_t i;
|
int32_t i;
|
||||||
int32_t rs;
|
int32_t rs;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
|
||||||
f = open_ecorecorddb(filename,&count,1);
|
f = open_ecorecorddb(filename,&count,1);
|
||||||
|
|
||||||
index = (ecorankidx_t*) ECOMALLOC(sizeof(ecorankidx_t) + sizeof(char*) * (count-1),
|
index = (ecorankidx_t*) ECOMALLOC(sizeof(ecorankidx_t) + sizeof(char*) * (count-1),
|
||||||
"Allocate rank index");
|
"Allocate rank index");
|
||||||
|
|
||||||
index->count=count;
|
index->count=count;
|
||||||
|
|
||||||
for (i=0; i < count; i++)
|
for (i=0; i < count; i++)
|
||||||
{
|
{
|
||||||
buffer = read_ecorecord(f,&rs);
|
buffer = read_ecorecord(f,&rs);
|
||||||
@ -27,21 +27,18 @@ ecorankidx_t *read_rankidx(const char *filename)
|
|||||||
"Allocate rank label");
|
"Allocate rank label");
|
||||||
strncpy(index->label[i],buffer,rs);
|
strncpy(index->label[i],buffer,rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t rank_index(const char* label,ecorankidx_t* ranks)
|
int32_t rank_index(const char* label,ecorankidx_t* ranks)
|
||||||
{
|
{
|
||||||
char **rep;
|
char **rep;
|
||||||
|
fprintf(stderr,"Looking for rank -%s-... ",label);
|
||||||
rep = bsearch(label,ranks->label,ranks->count,sizeof(char*),compareRankLabel);
|
rep = bsearch(label,ranks->label,ranks->count,sizeof(char*),compareRankLabel);
|
||||||
|
|
||||||
if (rep)
|
if (rep)
|
||||||
return rep-ranks->label;
|
return rep-ranks->label;
|
||||||
else
|
|
||||||
ECOERROR(ECO_NOTFOUND_ERROR,"Rank label not found");
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user