6b37de0e2b9a4f2402de85eefdc86bdc0806b1be tdreszer Tue Jan 29 14:17:41 2013 -0800 Corrected bug Angie found in previous checkin. 'Clone' is always a clone. Also changed lmBit routines to require lm, rather than suggest that it is optional. diff --git src/lib/bits.c src/lib/bits.c index 3148370..9c7ed7e 100644 --- src/lib/bits.c +++ src/lib/bits.c @@ -66,59 +66,56 @@ /* Clone bits. */ { int byteCount = ((bitCount+7)>>3); Bits* bits = needLargeZeroedMem(byteCount); memcpy(bits, orig, byteCount); return bits; } void bitFree(Bits **pB) /* Free bits. */ { freez(pB); } Bits *lmBitAlloc(struct lm *lm,int bitCount) -// Allocate bits. Optionally supply local memory. +// Allocate bits. Must supply local memory. { +assert(lm != NULL); int byteCount = ((bitCount+7)>>3); return lmAlloc(lm,byteCount); } Bits *lmBitRealloc(struct lm *lm,Bits *b, int bitCount, int newBitCount) -// Resize a bit array. If b is null, allocate a new array. Optionally use local memory. +// Resize a bit array. If b is null, allocate a new array. Must supply local memory. { +assert(lm != NULL); int byteCount = ((bitCount+7)>>3); int newByteCount = ((newBitCount+7)>>3); return lmAllocMoreMem(lm, b ,byteCount, newByteCount); } Bits *lmBitClone(struct lm *lm,Bits* orig, int bitCount) -// Clone bits. Optionally use local memory. +// Clone bits. Must supply local memory. { +assert(lm != NULL); int byteCount = ((bitCount+7)>>3); Bits* bits = lmAlloc(lm,byteCount); memcpy(bits, orig, byteCount); return bits; } -void lmBitFree(struct lm *lm,Bits **pB) -// Free bits. If allocated from local memory, this does nothing. -{ -*pB = NULL; // Just zero pointer -} - void bitSetOne(Bits *b, int bitIx) /* Set a single bit. */ { b[bitIx>>3] |= oneBit[bitIx&7]; } void bitClearOne(Bits *b, int bitIx) /* Clear a single bit. */ { b[bitIx>>3] &= ~oneBit[bitIx&7]; } void bitSetRange(Bits *b, int startIx, int bitCount) /* Set a range of bits. */ {