Use bitwise operators for ROUND_UP/DOWN and rename them

to ROUND_UP_POW2/ROUND_DOWN_POW2

svn path=/trunk/; revision=13585
This commit is contained in:
Gé van Geldorp 2005-02-15 19:26:13 +00:00
parent 14f94bc26a
commit 1217e4a19d

View file

@ -49,8 +49,8 @@
#define REG_EXTEND_HASH_TABLE_SIZE 4
#define REG_VALUE_LIST_CELL_MULTIPLE 4
#define ROUND_DOWN(N, S) ((N) - ((N) % (S)))
#define ROUND_UP(N, S) ROUND_DOWN((N) + (S) - 1, (S))
#define ROUND_UP_POW2(N,S) (((N) + (S) - 1) & ~((S) - 1))
#define ROUND_DOWN_POW2(N,S) ((N) & ~((S) - 1))
#define ABS_VALUE(V) (((V) < 0) ? -(V) : (V))
@ -326,7 +326,7 @@ CmiCreateDefaultRootKeyCell(PKEY_CELL RootKeyCell, PCHAR KeyName)
BaseKeyName = strrchr(KeyName, '\\') + 1;
NameSize = strlen(BaseKeyName);
CellSize = ROUND_UP(sizeof(KEY_CELL) + NameSize - 1, 16);
CellSize = ROUND_UP_POW2(sizeof(KEY_CELL) + NameSize - 1, 16);
memset (RootKeyCell, 0, CellSize);
RootKeyCell->CellSize = (ULONG)-(LONG)CellSize;
@ -786,7 +786,7 @@ CmiAllocateCell (PREGISTRY_HIVE RegistryHive,
*Block = NULL;
/* Round to 16 bytes multiple */
CellSize = ROUND_UP(CellSize, 16);
CellSize = ROUND_UP_POW2(CellSize, 16);
/* first search in free blocks */
NewBlock = NULL;