title: initializing a 2-D array of structs pointers in C
body: <p>I'm using <code>-std=gnu99</code> when I compile. Suppose I had a struct like this:</p>
  <pre><code>typedef struct Foo {
      char *quux;
      int baz;
  } Foo;
  </code></pre>
  <p>I noticed that you can initialize a 1D array of structs with NULL values in the heap like this:</p>
  <pre><code>Foo* bar[10] = {[0 ... 9] = NULL};
  </code></pre>
  <p>But how would I do this for a 2D array on the heap? Here is my attempt:</p>
  <pre><code>int depth = 10;
  int length = 10;
  Foo **bar;
  
  bar = malloc(sizeof(Foo) * length);
  
  for (int i = 0; i &lt; length; i++) {
  
      bar[i] = (Foo*) calloc(depth, sizeof(Foo));
  
  }
  </code></pre>
  <p>And when I go to release this memory, would I <code>free()</code> 10 times, or 100 times? And what about the variable length of foo.quux?</p>