simplify
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22859 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -53,19 +53,18 @@ krb5_copy_host_realm(krb5_context context,
|
|||||||
const krb5_realm *from,
|
const krb5_realm *from,
|
||||||
krb5_realm **to)
|
krb5_realm **to)
|
||||||
{
|
{
|
||||||
int n, i;
|
unsigned int n, i;
|
||||||
const krb5_realm *p;
|
const krb5_realm *p;
|
||||||
|
|
||||||
for (n = 0, p = from; *p != NULL; ++p)
|
for (n = 1, p = from; *p != NULL; ++p)
|
||||||
++n;
|
++n;
|
||||||
++n;
|
|
||||||
*to = malloc (n * sizeof(**to));
|
*to = calloc (n, sizeof(**to));
|
||||||
if (*to == NULL) {
|
if (*to == NULL) {
|
||||||
krb5_set_error_string (context, "malloc: out of memory");
|
krb5_set_error_string (context, "malloc: out of memory");
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
for (i = 0; i < n; ++i)
|
|
||||||
(*to)[i] = NULL;
|
|
||||||
for (i = 0, p = from; *p != NULL; ++p, ++i) {
|
for (i = 0, p = from; *p != NULL; ++p, ++i) {
|
||||||
(*to)[i] = strdup(*p);
|
(*to)[i] = strdup(*p);
|
||||||
if ((*to)[i] == NULL) {
|
if ((*to)[i] == NULL) {
|
||||||
|
Reference in New Issue
Block a user