title: Freeing malloc of unknown size
body: <p>I'm trying to free the malloc that is generated with a not fixed number of arrays.</p>
  
  <pre><code>char ** get_moves(){
      // some code
      char **moves = malloc(sizeof(char *) * k); // 'k', could ranges between 1~9
          if (!moves){
              return NULL;
          }
          for(int i = 0; i &lt; k; i++){
              moves[i] = malloc(82);
              if (!moves[i]) {
                  free (moves);
                  return NULL;
              }
      // more code
  
      return moves;
  }
  
  int main(){
  
      //some code
      char **res = get_moves(some_input);
      //more code
      for (int i = 0; i &lt; (sizeof(res)/sizeof(res[0)); i ++){
          free(res[i]);
      }
      free(res);
  
  }
  </code></pre>
  
  <p>In one of the inputs to get_move, res should have 2 arrays but the sizeof(res)/sizeof(res[0) gives me just 1.</p>
  
  <p>How is the proper way to handle this?</p>