title: Copying a struct member into a new struct
body: <p>I have a structure outlined below:</p>
  
  <pre><code>typedef struct {
      /* Device */
      UART_DEV uartDev;
      /* gpio */
      uint32_t gpiopio;
  } DEVICE;
  </code></pre>
  
  <p>In main.c I declare a new uart device and pass it to a function called configure();</p>
  
  <pre><code>/* main.c */
  
  static UART_DEV newUartDev;
  configure(newUartDev);
  </code></pre>
  
  <p><code>configure()</code> is located in test.c and inside the configure function I want to create a copy of the uart device and store it in global memory.</p>
  
  <pre><code>/* Test.c */
  
  UART_DEV globalUartDev;
  DEVICE globalDevice;
  
  static int configure(UART_DEV newUartDev) {
      /* Create a global copy of spi device */
      globalUartDev = newUartDev;
      DEVICE.uartDev = globalUartDev;
  
  }
  </code></pre>
  
  <p>Then I call another function in main.c <code>setTest</code>. setTest is located in test.c. I do not pass it the uart device declared in main.c instead I want to just use the global struct I created previously. <code>setTest</code> calls <code>open</code> in dev.c</p>
  
  <pre><code>/* test.c */
  
  setTest() {
      open(&amp;globalDevice);
  }
  </code></pre>
  
  <p>and finally I will use the uart device in open.</p>
  
  <pre><code>/* dev.c */
  int  open(DEVICE *dev) {
  read(dev-&gt;uartDev)
  }
  </code></pre>
  
  <p>Is this the correct way to create a copy and pass it around files?</p>