alloc.c 336 B

1234567891011121314151617181920
  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 * __ref 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. }