title: calloc not allocating correct data when returned to pointer reference from a dereferenced double pointer in a function
body: <p>I am trying to use calloc to dynamically allocate data to a struct pointer within another struct.</p>
  <p>If i allocate directly from the main routine, there is no issue.
  If i pass a double pointer to an initialization function with ** as parameter, and use the arrow operator to reference the address, the data is not properly allocated and i get a &quot;floating point error&quot; while encoding the hash.</p>
  <p>This code runs the way i want.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  
  /*create item structure, this will hold allocated pointers to the key/value elements.*/
  struct H_item_t{
      char* key;
      int* value;
  };
  typedef struct H_item_t H_item_t;
  
  /*create the table structure, this will point to the initial item address.*/
  struct HashTable_T {
      size_t size;
      H_item_t* items;
  };
  typedef struct HashTable_T HashTable_T;
  
  int encodeKey(HashTable_T* table, char* key){
      /*encode the string*/
      size_t index = 0;   //initialize value to full
      size_t length = strlen(key);    //get length of string
      size_t i = 0; //initialize loop;.
  
      for (; i &lt; length; i++) {
      index ^= (key[i]);
      };
      index %= table-&gt;size;
      return index;
  }
  
  void hashItem(HashTable_T* table, char* string, int value ){
      H_item_t* ptr1;
      int index = encodeKey(table,string);
      ptr1= &amp;table-&gt;items[index];
      ptr1-&gt;key=string;
      ptr1-&gt;value=(int)value;
  }
  
  int* getValue(HashTable_T* table, char* key){
      int index = encodeKey(table,key);
      H_item_t* ptr1;
      ptr1= &amp;table-&gt;items[index]; 
      return ptr1-&gt;value;
  }
  
  void deleteTable(HashTable_T* table){
      free(table-&gt;items);
      free(table);
  };
  
  void initTable(HashTable_T** table, int size){
  
      (*table) = (HashTable_T*)malloc(sizeof(HashTable_T));
      (*table)-&gt;items = (H_item_t*)calloc(size,sizeof(H_item_t));   
  };
  
  int main()
  {
  
  HashTable_T* ht1 = malloc(sizeof(HashTable_T));
  ht1-&gt;size=10;
  ht1-&gt;items=(H_item_t*)calloc(ht1-&gt;size,sizeof(H_item_t));
     
  hashItem(ht1,&quot;A&quot;,3);
  hashItem(ht1,&quot;B&quot;,2);
  hashItem(ht1,&quot;C&quot;,1);
  hashItem(ht1,&quot;D&quot;,100);
  
  printf(&quot;value returned from get: %x\n&quot;,(int)getValue(ht1,&quot;D&quot;));
  
  deleteTable(ht1);  
  }
  </code></pre>
  <p>If I use the initTable() fxn;</p>
  <pre><code>HashTable_T* ht1;
  initTable(&amp;ht1,10);
  </code></pre>
  <p>instead of;</p>
  <pre><code>HashTable_T* ht1 = malloc(sizeof(HashTable_T));
  ht1-&gt;size=10;
  ht1-&gt;items=(H_item_t*)calloc(ht1-&gt;size,sizeof(H_item_t));
  </code></pre>
  <p>I get &quot;floating point exception&quot; during runtime</p>