mirror of
https://github.com/torvalds/linux.git
synced 2024-12-04 18:13:04 +00:00
dcaee95a1b
2007/11/26, Patrick McHardy <kaber@trash.net>: > How about also switching vmalloc/get_free_pages to GFP_ZERO > and getting rid of the memset entirely while you're at it? > xfrm_hash: kmalloc + memset conversion to kzalloc fix to avoid memset entirely. Signed-off-by: Joonwoo Park <joonwpark81@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
40 lines
806 B
C
40 lines
806 B
C
/* xfrm_hash.c: Common hash table code.
|
|
*
|
|
* Copyright (C) 2006 David S. Miller (davem@davemloft.net)
|
|
*/
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/bootmem.h>
|
|
#include <linux/vmalloc.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/xfrm.h>
|
|
|
|
#include "xfrm_hash.h"
|
|
|
|
struct hlist_head *xfrm_hash_alloc(unsigned int sz)
|
|
{
|
|
struct hlist_head *n;
|
|
|
|
if (sz <= PAGE_SIZE)
|
|
n = kzalloc(sz, GFP_KERNEL);
|
|
else if (hashdist)
|
|
n = __vmalloc(sz, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL);
|
|
else
|
|
n = (struct hlist_head *)
|
|
__get_free_pages(GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO,
|
|
get_order(sz));
|
|
|
|
return n;
|
|
}
|
|
|
|
void xfrm_hash_free(struct hlist_head *n, unsigned int sz)
|
|
{
|
|
if (sz <= PAGE_SIZE)
|
|
kfree(n);
|
|
else if (hashdist)
|
|
vfree(n);
|
|
else
|
|
free_pages((unsigned long)n, get_order(sz));
|
|
}
|