Use bitwise operators for ROUND_UP/DOWN and rename them
to ROUND_UP_POW2/ROUND_DOWN_POW2
Modified: trunk/reactos/tools/mkhive/binhive.c
_____
Modified: trunk/reactos/tools/mkhive/binhive.c
--- trunk/reactos/tools/mkhive/binhive.c 2005-02-15 17:25:01 UTC
(rev 13584)
+++ trunk/reactos/tools/mkhive/binhive.c 2005-02-15 19:26:13 UTC
(rev 13585)
@@ -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 @@
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 @@
*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;
Show replies by date