Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - memtoptr() copy from an object to memory address http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 memtoptr()          Copy from an object to memory address
------------------------------------------------------------------------------
 Declaration
   memory.hdr

 Syntax
   proc memtoptr extern
   param       untyped  xObject, ;
         value _POINTER pMem, ;
         value uint     uLength

 Arguments
   xObject is the source memory object.
   pMem is the target memory address.
   uLength is the length of the copy operation.

 Return
   None.

 Description
   The procedure copies uLength bytes from the memory contents starting at the
   address of xObject to the memory block starting at pMem. The
   procedure can be used, as an example, to copy the contents of arrays
   to some other place. Use this procedure with extreme care, as it may
   overwrite important memory areas if called with an invalid address.

 Example
   #define EXAMPLE_MEMORY
   #include example.hdr

   proc Test_memtoptr
   vardef
      ptr( char ) pMem        // pointer
      char        cString     // string
   enddef
   pMem := malloc( 1000 )     // allocate working space
   ? *pMem                    // prints accidental value
   cString := "hello"
   memtoptr( cString, pMem, len( cString ) + 1 ) // write via function call
   ? *pMem                    // prints "hello"
   cString := "world"
   *pMem := cString           // write string to memory via pointer
   ? *pMem                    // prints "world"
   free( pMem )               // free allocation
   endproc

   proc main
   Test_memtoptr()
   endproc

See Also: memtosegoff() ptrtomem() segofftomem()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson