(_krb5_krbhost_info_move): new function

(_krb5_free_krbhst_info): expose to internal use


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16155 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2005-10-08 15:40:50 +00:00
parent 740f6b5deb
commit 66baee8800

View File

@@ -228,14 +228,37 @@ parse_hostspec(krb5_context context, struct krb5_krbhst_data *kd,
return hi;
}
static void
free_krbhst_info(krb5_krbhst_info *hi)
void
_krb5_free_krbhst_info(krb5_krbhst_info *hi)
{
if (hi->ai != NULL)
freeaddrinfo(hi->ai);
free(hi);
}
krb5_error_code
_krb5_krbhost_info_move(krb5_context context,
krb5_krbhst_info *from,
krb5_krbhst_info **to)
{
/* trailing NUL is included in structure */
*to = calloc(1, sizeof(**to) + strlen(from->hostname));
if(*to == NULL) {
krb5_set_error_string(context, "malloc - out of memory");
return ENOMEM;
}
(*to)->proto = from->proto;
(*to)->port = from->port;
(*to)->def_port = from->def_port;
(*to)->ai = from->ai;
from->ai = NULL;
(*to)->next = NULL;
strcpy((*to)->hostname, from->hostname);
return 0;
}
static void
append_host_hostinfo(struct krb5_krbhst_data *kd, struct krb5_krbhst_info *host)
{
@@ -245,7 +268,7 @@ append_host_hostinfo(struct krb5_krbhst_data *kd, struct krb5_krbhst_info *host)
if(h->proto == host->proto &&
h->port == host->port &&
strcmp(h->hostname, host->hostname) == 0) {
free_krbhst_info(host);
_krb5_free_krbhst_info(host);
return;
}
*kd->end = host;
@@ -747,7 +770,7 @@ krb5_krbhst_free(krb5_context context, krb5_krbhst_handle handle)
for (h = handle->hosts; h != NULL; h = next) {
next = h->next;
free_krbhst_info(h);
_krb5_free_krbhst_info(h);
}
free(handle->realm);