mymemoryblock = new MemoryBlock( 26000 )
and then use it.
Later, if you want a smaller one and don’t care about the content, you can do this somewhere else:
mymemoryblock = new MemoryBlock( 5000 )
but if you want the memoryblock to change size and keep the contents that’s when you
can try using .size
mymemoryblock.size = 5000
If the new size is bigger than the old, it should contain the same data (Xojo will have done this by allocating new memory and copying A to B
Not sure what they do for a smaller one, but in both cases you should not (IMO) rely on anything that stored the address in memory of the memoryblock before the resize.
Thanks, Kevin, Kem and Jeff.
mymemoryblock = new MemoryBlock( 5000 )
works! I would never have guessed this from my reading of the Xojo documentation. Perhaps Xojo should change the documentation into a Wiki so that useful information can be added to it (and obsolete information removed) by Xojo users.