From: Lucas De Marchi Date: Wed, 14 Dec 2011 17:05:03 +0000 (-0200) Subject: Use malloc + memset instead of calloc X-Git-Tag: v1~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=788ef0f7e69a766aa8d94b852d46fd0786233ddc;p=platform%2Fupstream%2Fkmod.git Use malloc + memset instead of calloc --- 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);