summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2011-12-14 15:05:03 -0200
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2011-12-14 15:05:03 -0200
commit788ef0f7e69a766aa8d94b852d46fd0786233ddc (patch)
treeae47ebe4481a7de0a0923c62a0e737722a90ee9a
parentd68ea2aedee8cdbd03897c5d94a5d3601465b140 (diff)
downloadkmod-788ef0f7e69a766aa8d94b852d46fd0786233ddc.tar.gz
kmod-788ef0f7e69a766aa8d94b852d46fd0786233ddc.tar.bz2
kmod-788ef0f7e69a766aa8d94b852d46fd0786233ddc.zip
Use malloc + memset instead of calloc
-rw-r--r--libkmod/libkmod-module.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index f9be534..faa736e 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -230,12 +230,14 @@ KMOD_EXPORT int kmod_module_new_from_name(struct kmod_ctx *ctx,
return 0;
}
- m = calloc(1, sizeof(*m) + namelen + 1);
+ m = malloc(sizeof(*m) + namelen + 1);
if (m == NULL) {
free(m);
return -ENOMEM;
}
+ memset(m, 0, sizeof(*m));
+
m->ctx = kmod_ref(ctx);
m->name = (char *)m + sizeof(*m);
memcpy(m->name, name_norm, namelen + 1);
@@ -344,10 +346,12 @@ KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx,
return 0;
}
- m = calloc(1, sizeof(*m) + namelen + 1);
+ m = malloc(sizeof(*m) + namelen + 1);
if (m == NULL)
return -errno;
+ memset(m, 0, sizeof(*m));
+
m->ctx = kmod_ref(ctx);
m->name = (char *)m + sizeof(*m);
memcpy(m->name, name, namelen);