[Box Backup-dev] COMMIT r248 - box/trunk/lib/backupclient
boxbackup-dev at fluffy.co.uk
boxbackup-dev at fluffy.co.uk
Tue Dec 20 08:13:22 GMT 2005
Author: martin
Date: 2005-12-20 08:13:21 +0000 (Tue, 20 Dec 2005)
New Revision: 248
Modified:
box/trunk/lib/backupclient/BackupStoreFile.h
Log:
Fix CodingChunkAlloc/Free for use on 32 and 64 bit platforms
Modified: box/trunk/lib/backupclient/BackupStoreFile.h
===================================================================
--- box/trunk/lib/backupclient/BackupStoreFile.h 2005-12-19 10:49:48 UTC (rev 247)
+++ box/trunk/lib/backupclient/BackupStoreFile.h 2005-12-20 08:13:21 UTC (rev 248)
@@ -123,19 +123,20 @@
uint8_t *a = (uint8_t*)malloc((Size) + (BACKUPSTOREFILE_CODING_BLOCKSIZE * 3));
if(a == 0) return 0;
// Align to main block size
- ASSERT(sizeof(uint32_t) == sizeof(void*)); // make sure casting the right pointer size, will need to fix on platforms with 64 bit pointers
- uint32_t adjustment = BACKUPSTOREFILE_CODING_BLOCKSIZE - (((uint32_t)(long)a) % BACKUPSTOREFILE_CODING_BLOCKSIZE);
+ ASSERT(sizeof(unsigned long) >= sizeof(void*)); // make sure casting the right pointer size
+ uint8_t adjustment = BACKUPSTOREFILE_CODING_BLOCKSIZE
+ - (uint8_t)(((unsigned long)a) % BACKUPSTOREFILE_CODING_BLOCKSIZE);
uint8_t *b = (a + adjustment);
// Store adjustment
- *b = (uint8_t)adjustment;
+ *b = adjustment;
// Return offset
return b + BACKUPSTOREFILE_CODING_OFFSET;
}
inline static void CodingChunkFree(void *Block)
{
// Check alignment is as expected
- ASSERT(sizeof(uint32_t) == sizeof(void*)); // make sure casting the right pointer size, will need to fix on platforms with 64 bit pointers
- ASSERT((((uint32_t)(long)Block) % BACKUPSTOREFILE_CODING_BLOCKSIZE) == BACKUPSTOREFILE_CODING_OFFSET);
+ ASSERT(sizeof(unsigned long) >= sizeof(void*)); // make sure casting the right pointer size
+ ASSERT((uint8_t)(((unsigned long)Block) % BACKUPSTOREFILE_CODING_BLOCKSIZE) == BACKUPSTOREFILE_CODING_OFFSET);
uint8_t *a = (uint8_t*)Block;
a -= BACKUPSTOREFILE_CODING_OFFSET;
// Adjust downwards...
More information about the Boxbackup-dev
mailing list