Hi,
Is there any way to get direct access to a buffer in a string class
similar to the MFC CString::GetBuffer()/CString::ReleaseBuffer() pair?
Inside the implementation of an XPCOM interface, I am calling a library
function that takes a raw pointer and a buffer length and writes a null
terminated string into it. I want to assign this string to a nsCString
which is returned from the interface. The easiest way would be to
request the string to have the max size buffer, write the data directly
into the strings buffer, then tell the string the actual size of the
data. This way there is only a single allocation.
e.g.
nsCString str;
int bufsiz = 1000;
str.SetLength( bufsiz );
char * p = str.GetBuffer();
rawpointerfn( p, &bufsiz );
str.SetLength( bufsiz );
Surely this is possible? Or do I have to double allocate (once manually,
once by the string)?
Regards,
Brodie.
- Re: direct access to ns[C]String buffer Brodie Thiesfield
- Re: direct access to ns[C]String buffer Benjamin Smedberg
- Re: direct access to ns[C]String buffer Brodie Thiesfield
