cache->objects = (PAGE_SIZE << cache->order) / cache->size;
- if (0 == cache->objects) return false;
+ if (0 == cache->objects) {
+ return false;
+ }
return true;
}
cache->partial_cnt = 0;
INIT_LIST_HEAD(&(cache->partial));
- if (!calculate_params(cache)) goto err;
+ if (!calculate_params(cache)) {
+ goto err;
+ }
return true;
err:
}
}
- if (cache->page == 0) return 0;
+ if (cache->page == 0) {
+ return 0;
+ }
object = cache->page->freelist;
void *kmalloc(size_t size, gfp_t gfpflags) {
unsigned int i;
kmem_cache_t *cache = 0;
+ void *addr = 0;
unsigned long flags;
irq_save(flags);
}
}
- void *addr = kmem_cache_alloc(cache, gfpflags);
+ // 如果没找到支持的cache则分配失败
+ if (0 == cache) {
+ goto err;
+ }
+
+ addr = kmem_cache_alloc(cache, gfpflags);
+err:
irq_restore(flags);
return addr;
printk("kmalloc addr %08x\n", (unsigned long) addr);
addrs[i] = addr;
}
-#endif
+#endifq
}