libxml C fun

Mark Ellis mark.uzumati at virgin.net
Mon Dec 2 08:30:35 PST 2002


On 2002.12.02 15:59 Billy O'Connor wrote:
> mark.uzumati at virgin.net (Mark Ellis) writes:
> 
> > gcc -g -O2 -o simplealfs -static simplealfs-simplealfs.o  -L/usr/lib
> > /usr/lib/libxml2.a -lz -lpthread -lm ../libalfs/.libs/libalfs.a -ldl
> >
> >
> > cut from simplealfs.c
> >
> >          char *xml = NULL;
> >          xmlDocPtr xmldoc = NULL;
> >
> > /* reads a file and stores it all in a string */
> >          xml = read_profile(profile);
> > 	if (xml == NULL) {
> >                  return 0;
> > 	}
> >
> >          profile_len = strlen(xml)+1;
> 
> That +1, is that neccessary when you're getting the strlen()?  That
> looks like an edge condition.
> 

I wasnt sure whether xmlParseMemory wanted the length of the string 
with or without the terminating NULL, hence the +1, though it doesnt 
work without it either.

Mark
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe alfs-discuss' in the subject header of the message



More information about the alfs-discuss mailing list