kmalloc: Streamline the code a little bit
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 10 Oct 2012 12:49:59 +0000 (20:49 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 10 Oct 2012 12:49:59 +0000 (20:49 +0800)
sys/kern/kern_slaballoc.c

index 3fc43d7..237365e 100644 (file)
@@ -829,9 +829,9 @@ kmalloc(unsigned long size, struct malloc_type *type, int flags)
         * Otherwise properly align the data according to the chunk size.
         */
        if (powerof2(size))
-           off = (off + size - 1) & ~(size - 1);
-       else
-           off = (off + align - 1) & ~(align - 1);
+           align = size;
+       off = (off + align - 1) & ~(align - 1);
+
        z->z_Magic = ZALLOC_SLAB_MAGIC;
        z->z_ZoneIndex = zi;
        z->z_NMax = (ZoneSize - off) / size;