FPS: useAsCString variants

Bulat Ziganshin bulat.ziganshin at gmail.com
Fri Jul 14 07:23:02 EDT 2006


Hello Donald,

Friday, July 14, 2006, 11:23:23 AM, you wrote:

> Ok, the story is:

> We'd like to be able to efficiently pass ByteStrings to C. However,
>     * CString has to be null terminated
>     * ByteStrings aren't null terminated.

yes, i know this story

> So, we have:
>     useAsCString,           which copies a ByteString, and adds a \0 byte, O(n)
>     unafeUseAsCString,      zero-copy version, assumes there's already a null byte, O(1)

> Now, on the other hand, we have the CStringLen type, which doesn't need
> a null byte. The CString type is isomorphic to a ByteString, so:

>     useAsCStringLen,        which is just a cast. O(1)
>     unsafeUseAsCStringLen   is a synonym for useAsCStringLen. 


what i mention is what unsafeUseAsCStringLen is not required because
it dubs useAsCStringLen, and unsafeUseAsCString is just not used in
FPS lib (although it may be useful for 3rd-party libs). whether it is
better to keep or omit them is a matter of taste


-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Libraries mailing list