On 12/02/2010 08:05 PM, Jason wrote:
ditto +1, just have to make a point of it in the docs
Absolutely, I will file separate bug(s) for that (doing this change will
definitely eliminate the requirement for ever having to call
TSHandleStringRelease(), which actually simplifies the usage of the APIs
a fair amount.
Fwiw, most of the doxygen docs for this already said the strings aren't
guaranteed to be NULL terminated. And most of the APIs I listed have a
note like this in the SDK doc:
Note: the returned string is not guaranteed to be null-terminated.
That note is obviously a lie, since up until now, they were guaranteed
to be NULL terminated, in a very expensive way (for this handful of
APIs). There's even a big section already in the docs, that says:
No null-terminated strings
In Traffic Server 5.2 (sic) and newer, you cannot assume that the
string data contained in
marshal buffers (data such as URLs and MIME fields) is stored in
null-terminated string
copies. This means that your plugins should always use the length
parameter when
retrieving or manipulating these strings.
I believe this whole nonsense of doing copies of strings on the heap,
and NULL terminate them, was some attempt to make the APIs compatible
with much older versions of Inktomi Traffic Server (which we don't need
to deal with obviously).
Cheers,
-- leif