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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to