title: Dereferencing the return of malloc() in C
body: <p>I have the need to allocate memory for an array of pointers to structs. The documentation for <code>malloc()</code> informs that the return from this function returns a pointer to the first block of memory that was allocated. Well, in my case I called the function like this:</p>
  
  <p><code>malloc(SIZE_TABLE*sizeof(struct structName*))</code> </p>
  
  <p>The problem being that, since malloc returns a pointer to this memory (containing pointers), it will thus return a 2-star pointer of type <code>structName</code>. </p>
  
  <p>Instead of having an extra line to assign the 2-star pointer and then dereference it, can you dereference the call itself?</p>
  
  <p>Instead of:</p>
  
  <p><code>struct structName** temp = malloc(SIZE_TABLE*sizeof(struct structName*))</code></p>
  
  <p><code>struct structName* temp2 = *(temp);</code></p>
  
  <p>Could you do something like:</p>
  
  <p><code>struct structName* temp2 = *( malloc(SIZE_TABLE*sizeof(struct structName*)) );</code></p>
  
  <p>I have done little when it comes to 2-star pointers, so if there is a better way to approach this problem (or if I am simply miss-understanding it all), please let me know.  </p>