Skip to content

Commit 69ac95f

Browse files
committed
Copy over final 0.2.0 lib2bit files.
1 parent 61b875c commit 69ac95f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib2bit/2bit.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ uint8_t getByteMaskFromOffset(int offset) {
275275

276276
void *twobitBasesWorker(TwoBit *tb, uint32_t tid, uint32_t start, uint32_t end, int fraction) {
277277
void *out;
278-
uint32_t tmp[4] = {0, 0, 0, 0}, len = end - start, i = 0, j = 0;
278+
uint32_t tmp[4] = {0, 0, 0, 0}, len = end - start + (start % 4), i = 0, j = 0;
279279
uint32_t blockStart, blockEnd, maskIdx = (uint32_t) -1, maskStart, maskEnd, foo;
280280
uint8_t *bytes = NULL, mask = 0, offset;
281281

@@ -293,8 +293,10 @@ void *twobitBasesWorker(TwoBit *tb, uint32_t tid, uint32_t start, uint32_t end,
293293
bytes = malloc(blockEnd - blockStart);
294294
if(!bytes) goto error;
295295

296-
//Set the initial mask
296+
//Set the initial mask, reset start/offset so we always deal with full bytes
297297
mask = getByteMaskFromOffset(offset);
298+
start = 4 * blockStart;
299+
offset = 0;
298300

299301
if(twobitSeek(tb, tb->idx->offset[tid] + blockStart) != 0) goto error;
300302
if(twobitRead(bytes, blockEnd - blockStart, 1, tb) != 1) goto error;

0 commit comments

Comments
 (0)