• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Do I need to free() after gethostbyname()?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Do I need to free() after gethostbyname()?


  • Subject: Do I need to free() after gethostbyname()?
  • From: Dave Camp <email@hidden>
  • Date: Wed, 29 Sep 2004 10:35:00 -0700

I've got some leaks in my program and ObjectAlloc seems to show a leak for every call to gethostbyname().

The man page for gethostbyname doesn't indicate I need to free the pointer that is returned and a google on 'gethostbyname free' yields some hits that indicate that on some systems the pointer is to a static struct and does not need to be freed, and on others it is malloc'd and does need to be freed.

What should I be doing on OS X?

For reference, the call stack looks like:

	malloc_zone_malloc
	malloc
	strdup
	copy_host
	cache_gethostbyname
	gethostbynameerrno
	gethostbyname

Thanks,
Dave
---
In English, every word can be verbed.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Do I need to free() after gethostbyname()?
      • From: Justin Walker <email@hidden>
  • Prev by Date: Re: OT: MPW over MacOS X
  • Next by Date: Re: Do I need to free() after gethostbyname()?
  • Previous by thread: Re: cfftpstream error handling
  • Next by thread: Re: Do I need to free() after gethostbyname()?
  • Index(es):
    • Date
    • Thread