title: Allocate an array of fixed size arrays (and passing it to a function)
body: <p>I have a function which expect a <code>wchar_t**</code>, I am allocating it:</p>
  
  <pre><code>wchar_t * * lFilterPatterns = malloc(aNumOfFilterPatterns*sizeof(wchar_t *));
  for (i = 0; i &lt; aNumOfFilterPatterns; i++)
  {
      lFilterPatterns[i] = malloc(MAX_PATH_OR_CMD*sizeof(wchar_t));
  }
  </code></pre>
  
  <p>is there a better/simpler way to make this allocation ?</p>
  
  <p>edit:
  I would prefer to call malloc once only.</p>
  
  <p>this has been proposed:</p>
  
  <pre><code>wchar_t (*lFilterPatterns)[MAX_PATH_OR_CMD] =
           malloc(aNumOfFilterPatterns * sizeof * lFilterPatterns);
  </code></pre>
  
  <p>but then the function complains:
  warning C4047: 'function' :</p>
  
  <pre><code>'wchar_t * *' differs in levels of indirection from 'wchar_t (*)[1024]'
  </code></pre>
  
  <p>can I cast 'wchar_t (*)[1024]' into 'wchar_t * *' ?</p>