Blame ares_free_hostent.c

Packit 514978
Packit 514978
/* Copyright 1998 by the Massachusetts Institute of Technology.
Packit 514978
 *
Packit 514978
 * Permission to use, copy, modify, and distribute this
Packit 514978
 * software and its documentation for any purpose and without
Packit 514978
 * fee is hereby granted, provided that the above copyright
Packit 514978
 * notice appear in all copies and that both that copyright
Packit 514978
 * notice and this permission notice appear in supporting
Packit 514978
 * documentation, and that the name of M.I.T. not be used in
Packit 514978
 * advertising or publicity pertaining to distribution of the
Packit 514978
 * software without specific, written prior permission.
Packit 514978
 * M.I.T. makes no representations about the suitability of
Packit 514978
 * this software for any purpose.  It is provided "as is"
Packit 514978
 * without express or implied warranty.
Packit 514978
 */
Packit 514978
Packit 514978
#include "ares_setup.h"
Packit 514978
Packit 514978
#ifdef HAVE_NETDB_H
Packit 514978
#include <netdb.h>
Packit 514978
#endif
Packit 514978
Packit 514978
#include "ares.h"
Packit 514978
#include "ares_private.h" /* for memdebug */
Packit 514978
Packit 514978
void ares_free_hostent(struct hostent *host)
Packit 514978
{
Packit 514978
  char **p;
Packit 514978
Packit 514978
  if (!host)
Packit 514978
    return;
Packit 514978
Packit 514978
  ares_free((char *)(host->h_name));
Packit 514978
  for (p = host->h_aliases; *p; p++)
Packit 514978
    ares_free(*p);
Packit 514978
  ares_free(host->h_aliases);
Packit 514978
  ares_free(host->h_addr_list[0]); /* no matter if there is one or many entries,
Packit 514978
                                 there is only one malloc for all of them */
Packit 514978
  ares_free(host->h_addr_list);
Packit 514978
  ares_free(host);
Packit 514978
}