Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 7443
b: refs/heads/master
c: dd39271
h: refs/heads/master
i:
  7441: f2c89e5
  7439: 96bfad2
v: v3
  • Loading branch information
Pekka J Enberg authored and Linus Torvalds committed Sep 7, 2005
1 parent 1c5400d commit 856da0d
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 24 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: 640e803376b9c4072f69fec42e304c974a631298
refs/heads/master: dd3927105b6f65afb7dac17682172cdfb86d3f00
16 changes: 15 additions & 1 deletion trunk/include/linux/slab.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,21 @@ static inline void *kmalloc(size_t size, unsigned int __nocast flags)
return __kmalloc(size, flags);
}

extern void *kcalloc(size_t, size_t, unsigned int __nocast);
extern void *kzalloc(size_t, unsigned int __nocast);

/**
* kcalloc - allocate memory for an array. The memory is set to zero.
* @n: number of elements.
* @size: element size.
* @flags: the type of memory to allocate.
*/
static inline void *kcalloc(size_t n, size_t size, unsigned int __nocast flags)
{
if (n != 0 && size > INT_MAX / n)
return NULL;
return kzalloc(n * size, flags);
}

extern void kfree(const void *);
extern unsigned int ksize(const void *);

Expand Down
3 changes: 1 addition & 2 deletions trunk/kernel/intermodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,14 @@ void inter_module_register(const char *im_name, struct module *owner, const void
struct list_head *tmp;
struct inter_module_entry *ime, *ime_new;

if (!(ime_new = kmalloc(sizeof(*ime), GFP_KERNEL))) {
if (!(ime_new = kzalloc(sizeof(*ime), GFP_KERNEL))) {
/* Overloaded kernel, not fatal */
printk(KERN_ERR
"Aiee, inter_module_register: cannot kmalloc entry for '%s'\n",
im_name);
kmalloc_failed = 1;
return;
}
memset(ime_new, 0, sizeof(*ime_new));
ime_new->im_name = im_name;
ime_new->owner = owner;
ime_new->userdata = userdata;
Expand Down
4 changes: 2 additions & 2 deletions trunk/kernel/params.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,8 @@ static void __init kernel_param_sysfs_setup(const char *name,
{
struct module_kobject *mk;

mk = kmalloc(sizeof(struct module_kobject), GFP_KERNEL);
memset(mk, 0, sizeof(struct module_kobject));
mk = kzalloc(sizeof(struct module_kobject), GFP_KERNEL);
BUG_ON(!mk);

mk->mod = THIS_MODULE;
kobj_set_kset_s(mk, module_subsys);
Expand Down
3 changes: 1 addition & 2 deletions trunk/kernel/power/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ struct pm_dev *pm_register(pm_dev_t type,
unsigned long id,
pm_callback callback)
{
struct pm_dev *dev = kmalloc(sizeof(struct pm_dev), GFP_KERNEL);
struct pm_dev *dev = kzalloc(sizeof(struct pm_dev), GFP_KERNEL);
if (dev) {
memset(dev, 0, sizeof(*dev));
dev->type = type;
dev->id = id;
dev->callback = callback;
Expand Down
3 changes: 1 addition & 2 deletions trunk/kernel/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,9 @@ EXPORT_SYMBOL(adjust_resource);
*/
struct resource * __request_region(struct resource *parent, unsigned long start, unsigned long n, const char *name)
{
struct resource *res = kmalloc(sizeof(*res), GFP_KERNEL);
struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);

if (res) {
memset(res, 0, sizeof(*res));
res->name = name;
res->start = start;
res->end = start + n - 1;
Expand Down
3 changes: 1 addition & 2 deletions trunk/kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,9 @@ struct workqueue_struct *__create_workqueue(const char *name,
struct workqueue_struct *wq;
struct task_struct *p;

wq = kmalloc(sizeof(*wq), GFP_KERNEL);
wq = kzalloc(sizeof(*wq), GFP_KERNEL);
if (!wq)
return NULL;
memset(wq, 0, sizeof(*wq));

wq->name = name;
/* We don't need the distraction of CPUs appearing and vanishing. */
Expand Down
18 changes: 6 additions & 12 deletions trunk/mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -2558,24 +2558,18 @@ void kmem_cache_free(kmem_cache_t *cachep, void *objp)
EXPORT_SYMBOL(kmem_cache_free);

/**
* kcalloc - allocate memory for an array. The memory is set to zero.
* @n: number of elements.
* @size: element size.
* 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 *kcalloc(size_t n, size_t size, unsigned int __nocast flags)
void *kzalloc(size_t size, unsigned int __nocast flags)
{
void *ret = NULL;

if (n != 0 && size > INT_MAX / n)
return ret;

ret = kmalloc(n * size, flags);
void *ret = kmalloc(size, flags);
if (ret)
memset(ret, 0, n * size);
memset(ret, 0, size);
return ret;
}
EXPORT_SYMBOL(kcalloc);
EXPORT_SYMBOL(kzalloc);

/**
* kfree - free previously allocated memory
Expand Down

0 comments on commit 856da0d

Please sign in to comment.