• 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
Re: Memory problem freeing strdup strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory problem freeing strdup strings


  • Subject: Re: Memory problem freeing strdup strings
  • From: Eric Albert <email@hidden>
  • Date: Fri, 2 Mar 2007 09:38:16 -0800

On Mar 2, 2007, at 8:43 AM, Allen Cronce wrote:

I'm tracking down a memory problem in some legacy code. What's happening
is MallocDebug will squawk with a warning anytime we try to "free" a
string allocated with "strdup".


So the following example code:

    char*    pszDebug    = strdup("The sky is falling!");
    free(pszDebug);

Will generate a warning like this:

    libMallocDebug[MyApp-20004]: free: target application attempted to
free pointer 0x51b4f0 that is not pointing to a malloc block.  The
address is not in memory used by the heap.

It looks like you're linking against libMallocDebug.a. Don't do that. (We shouldn't even ship the .a.) Instead, just launch your application with the MallocDebug application. That'll work properly with strdup and other functions inside Libc which call malloc.


Hope this helps,
Eric

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


  • Follow-Ups:
    • Re: Memory problem freeing strdup strings
      • From: Allen Cronce <email@hidden>
References: 
 >Memory problem freeing strdup strings (From: Allen Cronce <email@hidden>)

  • Prev by Date: Re: Threading Question
  • Next by Date: Re: Memory problem freeing strdup strings
  • Previous by thread: Memory problem freeing strdup strings
  • Next by thread: Re: Memory problem freeing strdup strings
  • Index(es):
    • Date
    • Thread