From 319fa07a42d70309912b8d53f2bc367b2c64cf67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Mon, 7 Apr 2008 18:49:40 +0000 Subject: [PATCH] simplify git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22859 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/krb5/copy_host_realm.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/krb5/copy_host_realm.c b/lib/krb5/copy_host_realm.c index 98ede4399..64fd71d2b 100644 --- a/lib/krb5/copy_host_realm.c +++ b/lib/krb5/copy_host_realm.c @@ -53,19 +53,18 @@ krb5_copy_host_realm(krb5_context context, const krb5_realm *from, krb5_realm **to) { - int n, i; + unsigned int n, i; const krb5_realm *p; - for (n = 0, p = from; *p != NULL; ++p) + for (n = 1, p = from; *p != NULL; ++p) ++n; - ++n; - *to = malloc (n * sizeof(**to)); + + *to = calloc (n, sizeof(**to)); if (*to == NULL) { krb5_set_error_string (context, "malloc: out of memory"); return ENOMEM; } - for (i = 0; i < n; ++i) - (*to)[i] = NULL; + for (i = 0, p = from; *p != NULL; ++p, ++i) { (*to)[i] = strdup(*p); if ((*to)[i] == NULL) {