Personally, I'd just use:
audio_setup_destination = audio_setup_source;
The above takes up about the same amount of object code as calling MemMove (14 for MemMove vs. 20 bytes in this particular case), is faster since you avoid the overhead of a system function call, and is more portable since it doesn't use any OS-specific API.
Keep in mind, however, that neither the above nor the use of MemMove perform a *deep* copy. That is, hLangVersion and the other MemHandles in the block will still refer to the same data as the original buffer. Care must be taken either to (a) dispose of those blocks only once regardless of how many audio_setup structure point to them, or (b) clone those as well using MemHandleNew and MemMove.
-- Keith
At 10:28 AM +0530 7/16/04, Lakshman wrote:
You shall use MemMove whose prototype is as follows:
Declared In MemoryMgr.h
Prototype Err MemMove (void* destP, const void* sourceP, Int32 numBytes)
Parameters destP - Pointer to destination.
sourceP - Pointer to source.
numBytes - Number of bytes to move.
In case of your structure, you do it as:
MemMove( &audio_setup_destination, &audio_setup_source, sizeof( AUDIO_SETUP) );
where audio_setup_destination and audio_setup_source are structure variables of the source and destination AUDIO_SETUP structures. For more details refer to Palm OS Reference.pdf which you can find in the Palmsource.com / developer / documentation.
Lakshman wrote:
You can use 'MemMove' function if the data is in dynamic heap memory. If the data is in data heap try using 'DmSet' or 'DmWrite' functions. Refer Palm OS Reference.pdf for details
Ritu Chawla wrote:
Hi , Is their any command in palm to do memcopy. I need to copy complete structure (Moveable chunk) . Here is the sample structure
typedef struct audio_setup { MemHandle hLangVersion; //char* MemHandle hAudioTestArray; //struct audio_test * Int32 nCurrentAudioTestValue; MemHandle hAudioChannelTrimPort; //struct audio_channel_trimport* MemHandle hPinkNoiseOrReferenceTone; //char* Int32 nCurrentAudioChannel; UInt16 nAudioTestArrayCount; }AUDIO_SETUP;
rgds, Ritu
-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
