@@ -144,8 +144,8 @@ append_int(char *restrict buf, int32_t value, int64_t offset, int64_t buflen)
144
144
}
145
145
146
146
static inline int64_t
147
- append_float (char * restrict buf , int32_t int32_value , float value , int64_t offset ,
148
- int64_t buflen )
147
+ append_float (
148
+ char * restrict buf , int32_t int32_value , float value , int64_t offset , int64_t buflen )
149
149
{
150
150
if (int32_value == VCZ_FLOAT32_MISSING_AS_INT32 ) {
151
151
return append_char (buf , '.' , offset , buflen );
@@ -204,8 +204,8 @@ string_all_missing(const char *restrict data, size_t item_size, size_t n)
204
204
}
205
205
206
206
static int64_t
207
- string_field_write_entry (const vcz_field_t * self , const void * data , char * buf ,
208
- int64_t buflen , int64_t offset )
207
+ string_field_write_entry (
208
+ const vcz_field_t * self , const void * data , char * buf , int64_t buflen , int64_t offset )
209
209
{
210
210
const char * source = (const char * ) data ;
211
211
size_t column , byte ;
@@ -297,8 +297,8 @@ float32_field_write_entry(const vcz_field_t *self, const void *restrict data,
297
297
}
298
298
299
299
static int64_t
300
- vcz_field_write_entry (const vcz_field_t * self , const void * data , char * buf ,
301
- int64_t buflen , int64_t offset )
300
+ vcz_field_write_entry (
301
+ const vcz_field_t * self , const void * data , char * buf , int64_t buflen , int64_t offset )
302
302
{
303
303
if (self -> type == VCZ_TYPE_INT ) {
304
304
if (self -> item_size == 4 ) {
@@ -403,7 +403,7 @@ vcz_field_init(vcz_field_t *self, const char *name, int type, size_t item_size,
403
403
404
404
static int64_t
405
405
vcz_variant_encoder_write_sample_gt (const vcz_variant_encoder_t * self , size_t variant ,
406
- size_t sample , char * buf , int64_t VCZ_UNUSED ( buflen ) , int64_t offset )
406
+ size_t sample , char * buf , int64_t buflen , int64_t offset )
407
407
{
408
408
const size_t ploidy = self -> gt .num_columns ;
409
409
size_t source_offset = variant * self -> num_samples * ploidy + sample * ploidy ;
@@ -420,18 +420,19 @@ vcz_variant_encoder_write_sample_gt(const vcz_variant_encoder_t *self, size_t va
420
420
421
421
for (ploid = 0 ; ploid < ploidy ; ploid ++ ) {
422
422
value = source [ploid ];
423
- if (value != VCZ_INT_FILL ) {
424
- if (ploid > 0 ) {
425
- buf [offset ] = sep ;
426
- offset ++ ;
427
- }
428
- if (value == VCZ_INT_MISSING ) {
429
- buf [offset ] = '.' ;
430
- offset ++ ;
431
- } else {
432
- offset += vcz_itoa (buf + offset , value );
423
+ if (value == VCZ_INT_FILL ) {
424
+ break ;
425
+ }
426
+ if (ploid > 0 ) {
427
+ offset = append_char (buf , sep , offset , buflen );
428
+ if (offset < 0 ) {
429
+ goto out ;
433
430
}
434
431
}
432
+ offset = append_int (buf , value , offset , buflen );
433
+ if (offset < 0 ) {
434
+ goto out ;
435
+ }
435
436
}
436
437
out :
437
438
return offset ;
@@ -543,7 +544,6 @@ vcz_variant_encoder_write_format_fields(const vcz_variant_encoder_t *self,
543
544
}
544
545
}
545
546
} else {
546
-
547
547
if (!gt_missing ) {
548
548
offset = append_string (buf , "GT:" , 3 , offset , buflen );
549
549
if (offset < 0 ) {
0 commit comments