[geos-devel] Re: gstrdup in CAPI implementation

Mateusz Loskot mateusz at loskot.net
Mon Jul 5 14:29:33 EDT 2010


On Wed, 2010-06-23 at 18:16 +0200, strk wrote:
> So, question is: are gstrdup and gstrdup_s
> functions in geos_ts.cpp intended to include
> or not a null termination ?
>
> Note that gstrdup_s takes a size but reads
> one more byte from input pointer:

Sandro,

Yes, these functions are dodgy, let's say, by design.
It is not really possible to make such interface consistent
and make one function working with both kinds of strings,
std::string and C-string.
The assumption is that user of gstrdup will learn
its implementation to understand how to use it.
Meaning, to keep value of size consistent with number of non-null
characters.

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net



More information about the geos-devel mailing list