alloc.c 343 B

12345678910111213141516171819
  1. #include <linux/types.h>
  2. #include <linux/init.h>
  3. #include <linux/slab.h>
  4. #include <linux/bootmem.h>
  5. #include <linux/string.h>
  6. #include <asm/setup.h>
  7. void * __init_refok zalloc_maybe_bootmem(size_t size, gfp_t mask)
  8. {
  9. void *p;
  10. if (slab_is_available())
  11. p = kzalloc(size, mask);
  12. else {
  13. p = memblock_virt_alloc(size, 0);
  14. }
  15. return p;
  16. }