title: Is this the right way to free memory in C?
body: <p>I have a struct in C as follows:</p>
  
  <pre><code>typedef struct ArrayStruct{
  float * array;
  size_t used;
  size_t size;
  }Array;
  </code></pre>
  
  <p>I initialize it as follows:</p>
  
  <pre><code>void initArray(Array *a, size_t initialSize) {
      a-&gt;array = (float *)malloc(initialSize * sizeof(float));
  
      if(a-&gt;array){
      }
      else{
          printf("OUT OF MEMORY 1!!\n\r");
      }
  
      a-&gt;used = 0;
      a-&gt;size = initialSize;
  }
  </code></pre>
  
  <p>My question is: Is the following code the right way to free up any memory being utilized by the struct :</p>
  
  <pre><code>void freeArray(Array *a) {
     a-&gt;array = NULL;    
     free(a-&gt;array);
     a-&gt;used = 0;
     a-&gt;size = 0;
  }
  </code></pre>
  
  <p>Please help. Thank you. :)</p>