From: Tobias Stoeckmann Date: Fri, 27 Sep 2024 20:15:59 +0000 (+0200) Subject: depmod: Use memdup X-Git-Tag: v34~279 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=568e9516fc3853a7abe860f29ef056663e1bbe24;p=thirdparty%2Fkmod.git depmod: Use memdup No need to clear newly allocated memory if source is copied into destination directly. Simplify code by using memdup from shared. Signed-off-by: Tobias Stoeckmann Reviewed-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/158 Signed-off-by: Lucas De Marchi --- diff --git a/tools/depmod.c b/tools/depmod.c index e736cac4..61999730 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -265,10 +265,9 @@ static int index_insert(struct index_node *node, const char *key, const char *va struct index_node *n; /* New child is copy of node with prefix[j+1..N] */ - n = calloc(1, sizeof(struct index_node)); + n = memdup(node, sizeof(struct index_node)); if (n == NULL) fatal_oom(); - memcpy(n, node, sizeof(struct index_node)); n->prefix = strdup(&prefix[j + 1]); if (n->prefix == NULL) fatal_oom();