• 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: Code Comments
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Code Comments


  • Subject: Re: Code Comments
  • From: Mike Abdullah <email@hidden>
  • Date: Sun, 09 Sep 2012 14:35:56 +0100

Further to existing comments:

* NSXMLParser supports NSInputStream directly these days; consider moving to that
* When releasing the parser because you're finished with it, might as well set the delegate to nil so you can't accidentally end up with a dangling pointer there

On 9 Sep 2012, at 04:00, koko <email@hidden> wrote:

> Does this code look correct in terms of memory management?
>
> It is called when a complete XML document is recognized (received via NSStream of a telnet host port)
>
> msgStart and msgEnd point to the beginning and ending <tags>
>
> the length check is arbitrary as I found without it I could get lengths that caused the dataWithBYtes to blow up
>
> the m_xmlParserDelegate object is instanced in IB
>
> - (void)startMessageParse:(void*)msgStart end:(void*)msgEnd
> {
>    NSInteger length = msgEnd-msgStart+1;
>    if(length > 0 && length < 4096)
>    {
>        NSData *data = [NSData dataWithBytes:msgStart length:length];
>        if(data)
>        {
>            NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:data];
>            [xmlParser setDelegate:m_xmlParserDelegate];
>            [xmlParser parse];
>            [data release];
>            [xmlParser release];
>        }
>    }
>    m_state = NEWMESSAGE;
> }
>
>
>
> -koko
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Code Comments
      • From: koko <email@hidden>
References: 
 >Code Comments (From: koko <email@hidden>)

  • Prev by Date: Re: KVO Question: How to programmatically determine if one object is observing another on a keyPath and context?
  • Next by Date: Re: KVO Question: How to programmatically determine if one object is observing another on a keyPath and context?
  • Previous by thread: Re: Code Comments
  • Next by thread: Re: Code Comments
  • Index(es):
    • Date
    • Thread