realbasic-plugins
[Top] [All Lists]

Dynamic access memoryblock questions

To: REALbasic Plugins <realbasic-plugins at lists dot realsoftware dot com>
Subject: Dynamic access memoryblock questions
From: Alfred Van Hoek <vanhoek at mac dot com>
Date: Tue, 22 Mar 2005 05:49:38 -0500
Delivered-to: realbasic-plugins at lists dot realsoftware dot com
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>

<Prev in Thread] Current Thread [Next in Thread>