title: Pointer magic: structs with pointer members and more
body: <p>I really don't have a clue how to give this question a good title - sorry for that.</p>
  
  <p>Just to know what's the goal of all this: pass a uint8_t variable pointer to bar() which does set it to 1 or 0, that I can check it's state inside my main. I do need zbar(), it's a thread and it does actually setting the value to 1 or 0</p>
  
  <p>So I have somewhere:</p>
  
  <pre><code>struct foo_t {
      ...
      uint8_t *state;
  };
  </code></pre>
  
  <p>and in main I go with:</p>
  
  <pre><code>int main(void) {
       uint8_t state = 0;
       bar(&amp;state);
  
       while(1) {
            if(state)
                //do something here
       }
  }
  </code></pre>
  
  <p>and here we have somewhere else in another sourcefile.</p>
  
  <pre><code>void bar(uint8_t *state) {
      struct foo_t *foo;    //using malloc here - don't worry
  
      foo-&gt;state = state;
  
      zbar(foo); 
  </code></pre>
  
  <p>}</p>
  
  <pre><code>void zbar(struct foo_t *arg) {
      if(condition)
         arg-&gt;state = 1;
      else
         arg-&gt;state = 0;
   }
  </code></pre>
  
  <p>How to make this working? o0
  zBar can actually access the arg struct, that's not the problem at all.</p>
  
  <p>Please don't worry why I do it so strange, it's used within threads etc.</p>