Article # 10, added by Geoworks, historical record
| first | previous | index | next | last |

@send dangers with pointer or temporary memory blocks




Question:
I get a BAD_DS error in Swat, and I think it's related to this code:

    {
        ...
        textOD = GeodeGetOptrNS( @FMVolumePathText );
        @send textOD::MSG_VIS_TEXT_REPLACE_ALL_PTR( pathBuffer,
                          LocalStringLength( pathBuffer ));
        MemFree( pathBufferHandle );
    }

Answer:
The problem is that the block you're using to send the string is
being freed before the text object sees it. If you change
@send to @call, the routine will work, since the caller will be
blocked until the text object is done with the memory block. After the text
object is done, then your routine will continue with the next line of code,
namely the MemFree.