title: When to use static inline instead of regular functions
body: <p>When I inspect other people's codes, I sometimes encounter static inline functions implemented in header files as opposed to regular function implementations in C files.</p>
  
  <p>For example, <code>cache.h</code> header file (<a href="https://github.com/git/git/blob/master/cache.h" rel="nofollow">https://github.com/git/git/blob/master/cache.h</a>) of <code>git</code> contains many such functions. One of them is copied below;</p>
  
  <pre><code>static inline void copy_cache_entry(struct cache_entry *dst,
                      const struct cache_entry *src)
  {
      unsigned int state = dst-&gt;ce_flags &amp; CE_HASHED;
  
      /* Don't copy hash chain and name */
      memcpy(&amp;dst-&gt;ce_stat_data, &amp;src-&gt;ce_stat_data,
              offsetof(struct cache_entry, name) -
              offsetof(struct cache_entry, ce_stat_data));
  
      /* Restore the hash state */
      dst-&gt;ce_flags = (dst-&gt;ce_flags &amp; ~CE_HASHED) | state;
  }
  </code></pre>
  
  <p>I was wondering what are the advantages of using static inline functions compared to regular functions. Is there any guideline one can use to choose which style to adapt?</p>