• 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: I confirmed ONE problem - not sure how to fix it though.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: I confirmed ONE problem - not sure how to fix it though.


  • Subject: Re: I confirmed ONE problem - not sure how to fix it though.
  • From: Sebastien Metrot <email@hidden>
  • Date: Wed, 05 Apr 2006 10:33:08 +0200

new char(100) allocates ONE char and sets it to 100. You want new char[100].

Cheers,

Sebastien


John Draper wrote:

Hi,

In my code, I do this...

 m_MyExtIP     = new char(100);

I run it with GuardMalloc, and it crashes here...

void
infoServer::setExtIP(char *ip)
{
if (m_MyExtIP == NULL) {
m_MyExtIP = new char(100);
}
strcpy(m_MyExtIP, ip); <---- This causes the crash. The size of the string is 16 bytes
}


But I allocate 100 bytes... and why when I do the 2nd alloc, it allocates
the 2nd one just 16 bytes past it, unstead of 100 bytes... Whats up with this?


John
_______________________________________________
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



_______________________________________________ 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
References: 
 >I confirmed ONE problem - not sure how to fix it though. (From: John Draper <email@hidden>)

  • Prev by Date: I confirmed ONE problem - not sure how to fix it though.
  • Next by Date: Re: Seeking advice on debugging "real time" programs.
  • Previous by thread: I confirmed ONE problem - not sure how to fix it though.
  • Next by thread: Re: I confirmed ONE problem - not sure how to fix it though.
  • Index(es):
    • Date
    • Thread