Skip to content

Commit e68e30b

Browse files
daviesrobwhitwham
authored andcommitted
Wrap a couple more calloc, malloc and realloc calls
Needed when using add_sat, prod_sat functions. A couple can also be converted to the _pse variants.
1 parent 941deb4 commit e68e30b

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

cram/cram_encode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2107,7 +2107,7 @@ int cram_encode_container(cram_fd *fd, cram_container *c) {
21072107
// slice can start aggregating them from the start again.
21082108
if (c->tags_used->n_occupied) {
21092109
int ntags = c->tags_used->n_occupied;
2110-
s->aux_block = calloc(hts_prod_sat2(ntags, 2), sizeof(*s->aux_block));
2110+
s->aux_block = hts_calloc(hts_prod_sat2(ntags, 2), sizeof(*s->aux_block));
21112111
if (!s->aux_block)
21122112
return -1;
21132113

faidx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ static char *fai_retrieve(const faidx_t *fai, const faidx1_t *val,
744744
}
745745

746746
// Over-allocate so there is extra space for one end-of-line sequence
747-
buffer = malloc(hts_add_sat3(end - beg, val->line_len - val->line_blen, 1));
747+
buffer = hts_malloc(hts_add_sat3(end - beg, val->line_len - val->line_blen, 1));
748748
if (!buffer) {
749749
*len = -1;
750750
return NULL;

realn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ int sam_prob_realn(bam1_t *b, const char *ref, hts_pos_t ref_len, int flag) {
220220
}
221221

222222
assert(bq == NULL); // bq was used above, but should now be NULL
223-
bq = malloc(hts_add_sat2(hts_prod_sat2(align_lqseq, 3), lref));
223+
bq = hts_malloc_pse(3, align_lqseq, 0, lref);
224224
if (!bq) goto fail;
225225
q = bq + align_lqseq;
226226
tseq = q + align_lqseq;

sam.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3410,7 +3410,7 @@ static void *sam_dispatcher_read(void *vp) {
34103410
// entire buffer is part of a single line
34113411
if (cp == l->data) {
34123412
line_frag = l->data_size;
3413-
char *rp = realloc(l->data, hts_add_sat2(hts_prod_sat2(l->alloc, 2), 8));
3413+
char *rp = hts_realloc_pse(l->data, 2, l->alloc, 0, 8);
34143414
if (!rp)
34153415
goto err;
34163416
l->alloc *= 2;

0 commit comments

Comments
 (0)