Linux Audio

Check our new training course

Loading...
v4.17
 1// SPDX-License-Identifier: GPL-2.0
 2#include <linux/types.h>
 3#include <linux/init.h>
 4#include <linux/slab.h>
 5#include <linux/bootmem.h>
 6#include <linux/string.h>
 7#include <asm/setup.h>
 8
 9
10void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask)
11{
12	void *p;
13
14	if (slab_is_available())
15		p = kzalloc(size, mask);
16	else {
17		p = memblock_virt_alloc(size, 0);
 
 
18	}
19	return p;
20}
v3.5.6
 
 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
 8
 9void * __init_refok zalloc_maybe_bootmem(size_t size, gfp_t mask)
10{
11	void *p;
12
13	if (mem_init_done)
14		p = kzalloc(size, mask);
15	else {
16		p = alloc_bootmem(size);
17		if (p)
18			memset(p, 0, size);
19	}
20	return p;
21}