From 1217e4a19d796e023259f0e1a61bd7f9b027a2b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Tue, 15 Feb 2005 19:26:13 +0000 Subject: [PATCH] Use bitwise operators for ROUND_UP/DOWN and rename them to ROUND_UP_POW2/ROUND_DOWN_POW2 svn path=/trunk/; revision=13585 --- reactos/tools/mkhive/binhive.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/reactos/tools/mkhive/binhive.c b/reactos/tools/mkhive/binhive.c index f28f7131aad..d9788cc0420 100644 --- a/reactos/tools/mkhive/binhive.c +++ b/reactos/tools/mkhive/binhive.c @@ -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;