Use malloc + memset instead of calloc
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Wed, 14 Dec 2011 17:05:03 +0000 (15:05 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Wed, 14 Dec 2011 17:05:03 +0000 (15:05 -0200)
libkmod/libkmod-module.c

index f9be534..faa736e 100644 (file)
@@ -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);