Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 23506
b: refs/heads/master
c: 40c07ae
h: refs/heads/master
v: v3
  • Loading branch information
Pekka Enberg authored and Linus Torvalds committed Mar 25, 2006
1 parent 3b23256 commit 65c7c4d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a8c0f9a41f88da703ade33f9c1626a55c786e8bb
refs/heads/master: 40c07ae8daa659b8feb149c84731629386873c16
30 changes: 27 additions & 3 deletions trunk/include/linux/slab.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,30 @@ static inline void *kmalloc(size_t size, gfp_t flags)
return __kmalloc(size, flags);
}

extern void *kzalloc(size_t, gfp_t);
extern void *__kzalloc(size_t, gfp_t);

static inline void *kzalloc(size_t size, gfp_t flags)
{
if (__builtin_constant_p(size)) {
int i = 0;
#define CACHE(x) \
if (size <= x) \
goto found; \
else \
i++;
#include "kmalloc_sizes.h"
#undef CACHE
{
extern void __you_cannot_kzalloc_that_much(void);
__you_cannot_kzalloc_that_much();
}
found:
return kmem_cache_zalloc((flags & GFP_DMA) ?
malloc_sizes[i].cs_dmacachep :
malloc_sizes[i].cs_cachep, flags);
}
return __kzalloc(size, flags);
}

/**
* kcalloc - allocate memory for an array. The memory is set to zero.
Expand Down Expand Up @@ -161,21 +184,22 @@ void *kmem_cache_zalloc(struct kmem_cache *, gfp_t);
void kmem_cache_free(struct kmem_cache *c, void *b);
const char *kmem_cache_name(struct kmem_cache *);
void *kmalloc(size_t size, gfp_t flags);
void *kzalloc(size_t size, gfp_t flags);
void *__kzalloc(size_t size, gfp_t flags);
void kfree(const void *m);
unsigned int ksize(const void *m);
unsigned int kmem_cache_size(struct kmem_cache *c);

static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
{
return kzalloc(n * size, flags);
return __kzalloc(n * size, flags);
}

#define kmem_cache_shrink(d) (0)
#define kmem_cache_reap(a)
#define kmem_ptr_validate(a, b) (0)
#define kmem_cache_alloc_node(c, f, n) kmem_cache_alloc(c, f)
#define kmalloc_node(s, f, n) kmalloc(s, f)
#define kzalloc(s, f) __kzalloc(s, f)
#define ____kmalloc kmalloc

#endif /* CONFIG_SLOB */
Expand Down
6 changes: 3 additions & 3 deletions trunk/mm/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
#include <asm/uaccess.h>

/**
* kzalloc - allocate memory. The memory is set to zero.
* __kzalloc - allocate memory. The memory is set to zero.
* @size: how many bytes of memory are required.
* @flags: the type of memory to allocate.
*/
void *kzalloc(size_t size, gfp_t flags)
void *__kzalloc(size_t size, gfp_t flags)
{
void *ret = ____kmalloc(size, flags);
if (ret)
memset(ret, 0, size);
return ret;
}
EXPORT_SYMBOL(kzalloc);
EXPORT_SYMBOL(__kzalloc);

/*
* kstrdup - allocate space for and copy an existing string
Expand Down

0 comments on commit 65c7c4d

Please sign in to comment.