Re: characterData

Sebastian Pipping <[email protected]>
Newsgroups gmane.text.xml.expat.general
Message-ID <[email protected]>
Gert Cuykens wrote:
> On 7/21/07, Nick MacDonald <[email protected]> wrote:
>> Since you are NOT guaranteed to get only ONE CharacterData handler
>> call, you should really be writing:
>>
>> static void
>> characterData(void *userData, const XML_Char *s, int l)
>> {
>>   PAGE *page = (PAGE *)userData;
>>   if (NULL == page->data)
>>   {
>>     char *data=malloc(l);
>>     memcpy(data,s,l);
>>     page->data=data;
>>     page->dataSize=l;  /* a new structure member */
>>   }
>>   else
>>   {
>>     char *data=realloc(data, l+page->dataSize);
>>     memcpy(data+page->dataSize,s,l);
>>     page->data=data;
>>     page->dataSize+=l;
>>   }
>> }
>>
> 
> Thanks :)

---------------------------------------
I still wonder how all this can work
without zero-termination. Am I missing
something?



Sebastian
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.