Index: src/OFBitSetCharacterSet.h ================================================================== --- src/OFBitSetCharacterSet.h +++ src/OFBitSetCharacterSet.h @@ -21,11 +21,11 @@ OF_ASSUME_NONNULL_BEGIN @interface OFBitSetCharacterSet: OFCharacterSet { - unsigned char *_bitset; + unsigned long *_bitSet; size_t _size; } @end OF_ASSUME_NONNULL_END Index: src/OFBitSetCharacterSet.m ================================================================== --- src/OFBitSetCharacterSet.m +++ src/OFBitSetCharacterSet.m @@ -40,27 +40,29 @@ size_t length = string.length; for (size_t i = 0; i < length; i++) { OFUnichar c = characters[i]; - if (c / CHAR_BIT >= _size) { + if (c / OF_ULONG_BIT >= _size) { size_t newSize; if (UINT32_MAX - c < 1) @throw [OFOutOfRangeException exception]; - newSize = OFRoundUpToPowerOf2(CHAR_BIT, c + 1) / - CHAR_BIT; + newSize = OFRoundUpToPowerOf2(OF_ULONG_BIT, + c + 1) / OF_ULONG_BIT; - _bitset = OFResizeMemory(_bitset, newSize, 1); - memset(_bitset + _size, '\0', newSize - _size); + _bitSet = OFResizeMemory(_bitSet, newSize, + sizeof(unsigned long)); + memset(_bitSet + _size, '\0', + (newSize - _size) * sizeof(unsigned long)); _size = newSize; } - OFBitsetSet(_bitset, c); + OFBitSetSet(_bitSet, c); } objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @@ -70,18 +72,18 @@ return self; } - (void)dealloc { - OFFreeMemory(_bitset); + OFFreeMemory(_bitSet); [super dealloc]; } - (bool)characterIsMember: (OFUnichar)character { - if (character / CHAR_BIT >= _size) + if (character / OF_ULONG_BIT >= _size) return false; - return OFBitsetIsSet(_bitset, character); + return OFBitSetIsSet(_bitSet, character); } @end Index: src/OFSecureData.m ================================================================== --- src/OFSecureData.m +++ src/OFSecureData.m @@ -42,11 +42,11 @@ #if defined(HAVE_MMAP) && defined(HAVE_MLOCK) && defined(MAP_ANON) static const size_t chunkSize = 16; struct Page { struct Page *next, *previous; - void *map; + unsigned long *map; unsigned char *page; }; # if defined(OF_HAVE_COMPILER_TLS) static thread_local struct Page *firstPage = NULL; @@ -100,12 +100,12 @@ static struct Page * addPage(bool allowPreallocated) { size_t pageSize = [OFSystemInfo pageSize]; - size_t mapSize = OFRoundUpToPowerOf2(CHAR_BIT, pageSize / chunkSize) / - CHAR_BIT; + size_t mapSize = OFRoundUpToPowerOf2(OF_ULONG_BIT, + pageSize / chunkSize) / OF_ULONG_BIT; struct Page *page; # if !defined(OF_HAVE_COMPILER_TLS) && defined(OF_HAVE_THREADS) struct Page *lastPage; # endif @@ -142,11 +142,11 @@ } } page = OFAllocMemory(1, sizeof(*page)); @try { - page->map = OFAllocZeroedMemory(1, mapSize); + page->map = OFAllocZeroedMemory(mapSize, sizeof(unsigned long)); } @catch (id e) { OFFreeMemory(page); @throw e; } @try { @@ -184,14 +184,14 @@ } static void removePageIfEmpty(struct Page *page) { - unsigned char *map = page->map; + unsigned long *map = page->map; size_t pageSize = [OFSystemInfo pageSize]; - size_t mapSize = OFRoundUpToPowerOf2(CHAR_BIT, pageSize / chunkSize) / - CHAR_BIT; + size_t mapSize = OFRoundUpToPowerOf2(OF_ULONG_BIT, + pageSize / chunkSize) / OF_ULONG_BIT; for (size_t i = 0; i < mapSize; i++) if (map[i] != 0) return; @@ -227,11 +227,11 @@ chunks = chunksLeft = bytes / chunkSize; firstChunk = 0; pageSize = [OFSystemInfo pageSize]; for (i = 0; i < pageSize / chunkSize; i++) { - if (OFBitsetIsSet(page->map, i)) { + if (OFBitSetIsSet(page->map, i)) { chunksLeft = chunks; firstChunk = i + 1; continue; } @@ -239,11 +239,11 @@ break; } if (chunksLeft == 0) { for (size_t j = firstChunk; j < firstChunk + chunks; j++) - OFBitsetSet(page->map, j); + OFBitSetSet(page->map, j); return page->page + (chunkSize * firstChunk); } return NULL; @@ -259,11 +259,11 @@ chunkIndex = ((uintptr_t)pointer - (uintptr_t)page->page) / chunkSize; OFZeroMemory(pointer, bytes); for (size_t i = 0; i < chunks; i++) - OFBitsetClear(page->map, chunkIndex + i); + OFBitSetClear(page->map, chunkIndex + i); } #endif @implementation OFSecureData @synthesize allowsSwappableMemory = _allowsSwappableMemory; Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -643,11 +643,14 @@ return; #ifdef OF_MSDOS gotoxy(column + 1, wherey()); #else - [self writeFormat: @"\033[%uG", column + 1]; + if (column == 0) + [self writeString: @"\r"]; + else + [self writeFormat: @"\033[%uG", column + 1]; #endif } - (void)setCursorPosition: (OFPoint)position { Index: src/macros.h ================================================================== --- src/macros.h +++ src/macros.h @@ -938,26 +938,28 @@ * @return The specified value rounded up to the specified power of two */ #define OFRoundUpToPowerOf2(pow2, value) \ (((value) + (pow2) - 1) & ~((pow2) - 1)) +#define OF_ULONG_BIT (sizeof(unsigned long) * CHAR_BIT) + static OF_INLINE bool -OFBitsetIsSet(unsigned char *_Nonnull storage, size_t idx) +OFBitSetIsSet(unsigned long *_Nonnull storage, size_t idx) { - return storage[idx / CHAR_BIT] & (1u << (idx % CHAR_BIT)); + return storage[idx / OF_ULONG_BIT] & (1ul << (idx % OF_ULONG_BIT)); } static OF_INLINE void -OFBitsetSet(unsigned char *_Nonnull storage, size_t idx) +OFBitSetSet(unsigned long *_Nonnull storage, size_t idx) { - storage[idx / CHAR_BIT] |= (1u << (idx % CHAR_BIT)); + storage[idx / OF_ULONG_BIT] |= (1ul << (idx % OF_ULONG_BIT)); } static OF_INLINE void -OFBitsetClear(unsigned char *_Nonnull storage, size_t idx) +OFBitSetClear(unsigned long *_Nonnull storage, size_t idx) { - storage[idx / CHAR_BIT] &= ~(1u << (idx % CHAR_BIT)); + storage[idx / OF_ULONG_BIT] &= ~(1ul << (idx % OF_ULONG_BIT)); } static OF_INLINE void OFZeroMemory(void *_Nonnull buffer_, size_t length) {