Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move bcf_dec_int1() bcf_dec_size() defs from vcf.h -> vcf.c #275

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 2 additions & 21 deletions htslib/vcf.h
Original file line number Diff line number Diff line change
Expand Up @@ -874,33 +874,14 @@ static inline void bcf_enc_int1(kstring_t *s, int32_t x)
}
}

static inline int32_t bcf_dec_int1(const uint8_t *p, int type, uint8_t **q)
{
if (type == BCF_BT_INT8) {
*q = (uint8_t*)p + 1;
return *(int8_t*)p;
} else if (type == BCF_BT_INT16) {
*q = (uint8_t*)p + 2;
return *(int16_t*)p;
} else {
*q = (uint8_t*)p + 4;
return *(int32_t*)p;
}
}
int32_t bcf_dec_int1(const uint8_t *p, int type, uint8_t **q);

static inline int32_t bcf_dec_typed_int1(const uint8_t *p, uint8_t **q)
{
return bcf_dec_int1(p + 1, *p&0xf, q);
}

static inline int32_t bcf_dec_size(const uint8_t *p, uint8_t **q, int *type)
{
*type = *p & 0xf;
if (*p>>4 != 15) {
*q = (uint8_t*)p + 1;
return *p>>4;
} else return bcf_dec_typed_int1(p + 1, q);
}
int32_t bcf_dec_size(const uint8_t *p, uint8_t **q, int *type);

#ifdef __cplusplus
}
Expand Down
24 changes: 24 additions & 0 deletions vcf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3375,3 +3375,27 @@ int bcf_get_format_values(const bcf_hdr_t *hdr, bcf1_t *line, const char *tag, v
return nsmpl*fmt->n;
}


int32_t bcf_dec_int1(const uint8_t *p, int type, uint8_t **q)
{
if (type == BCF_BT_INT8) {
*q = (uint8_t*)p + 1;
return *(int8_t*)p;
} else if (type == BCF_BT_INT16) {
*q = (uint8_t*)p + 2;
return *(int16_t*)p;
} else {
*q = (uint8_t*)p + 4;
return *(int32_t*)p;
}
}

int32_t bcf_dec_size(const uint8_t *p, uint8_t **q, int *type)
{
*type = *p & 0xf;
if (*p>>4 != 15) {
*q = (uint8_t*)p + 1;
return *p>>4;
} else return bcf_dec_typed_int1(p + 1, q);
}