ares_free_hostent.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* Copyright 1998 by the Massachusetts Institute of Technology.
  2. *
  3. * Permission to use, copy, modify, and distribute this
  4. * software and its documentation for any purpose and without
  5. * fee is hereby granted, provided that the above copyright
  6. * notice appear in all copies and that both that copyright
  7. * notice and this permission notice appear in supporting
  8. * documentation, and that the name of M.I.T. not be used in
  9. * advertising or publicity pertaining to distribution of the
  10. * software without specific, written prior permission.
  11. * M.I.T. makes no representations about the suitability of
  12. * this software for any purpose. It is provided "as is"
  13. * without express or implied warranty.
  14. */
  15. #include "ares_setup.h"
  16. #ifdef HAVE_NETDB_H
  17. #include <netdb.h>
  18. #endif
  19. #include "ares.h"
  20. #include "ares_private.h" /* for memdebug */
  21. void ares_free_hostent(struct hostent *host)
  22. {
  23. char **p;
  24. if (!host)
  25. return;
  26. ares_free((char *)(host->h_name));
  27. for (p = host->h_aliases; *p; p++)
  28. ares_free(*p);
  29. ares_free(host->h_aliases);
  30. ares_free(host->h_addr_list[0]); /* no matter if there is one or many entries,
  31. there is only one malloc for all of them */
  32. ares_free(host->h_addr_list);
  33. ares_free(host);
  34. }