OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Refreshed genx.h, plus some plans

[ Lists Home | Date Index | Thread Index ]

Rich Salz:
> >
> > Don't you want to know if genx is going to copy the pointers or copy the
> > data pointed to by them?
> 
> doh, never mind that reason; typo/brain-damage.
> 
> I think it's useful to be able to know if an API is going to modify the
> input parameters at all.  for example, without const, you don't know --
> outside of reading the code, or perhaps the documentation -- if this will
> segfault or not
>     genxAddText(w, "asdfasdfasdf");
> Now, that's unlikely, but the add bounded text might try to cheat and
> temporarily insert a \0 byte and then replace it.  If the compiler puts
> fixed text strings into read-only memory, as it is free to do, then such
> a technique would probably segfault.

This is not an interface issue. This possible fault is not because
'const' is or is not in the interface, but because the possible implementation 
is bad (no one would stop an implementor who just casts (const char *)
to (char *)).

On the other hand, following a simple rule not to modify a memory address
you didn't provide; unless specifically asked to, is easy and efficient.

Will all the respect to the Committee which added this keyword to C, it
is useless and annoying.

David Tolpin




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS