When Operator_Convert access on a memoryblock is requested, and for the sake
of simplicity leaving out the dynamic access apis:
I would convert a REALstring to a memoryblock by calling REALNewMemoryBlock
with the length of the string and then do the conversion:
XMemoryStream::XMemoryStream(REALstring s)
{
XString xs = s;
self = (REALobject)REALNewMemoryBlock(xs.length());
MemoryBlock_FromString((REALmemoryBlock)self, s);
s.unlock();
}
Similarly:
XMemoryStream::XMemoryStream(void* buffer);
the conversion of a Ptr would require knowing the length of the buffer. My
guess though would be to create a memoryblock with a length of 0, because
when REALbasic is calling the Operator_Convert routines, it will the
determine the length of a string or a pointer. Am I correct here?
However, it seems that calling REALNewMemoryBlock(0) would result in a nil
pointer, contrary to calling memblock = new memBlock(0) in Realbasic?
So how should I address these potential caveats?
Alfred
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|