title: Error:free(): invalid next size (fast)
body: <p>When I am freeing my memory in this part of code...i am getting an error showing as :free(): invalid next size (fast)</p>
  
  <pre><code>int insertRecord(char *record,int recordSize,long dataPageNumber)
  {
  datapage *dataPage=(datapage *)malloc(sizeof(datapage));
  readPage(dataPage,dataPageNumber);
  
  slotentry slot;
  
  //for checking and freeslotnumber storage
  int freeSlotNumber=-1;
  int negativeFlag=0;
  int freeFlag=0;
  
  if(recordSize+sizeof(slotentry)&lt;=dataPage-&gt;cfs)
  {
      slot.slotsize = recordSize;
      slot.slotaddress = dataPage-&gt;cfsptr;
      dataPage-&gt;cfs -= (recordSize+sizeof(slotentry));
      dataPage-&gt;cfsptr += recordSize;
      dataPage-&gt;slotcount++;
  
      memcpy(&amp;dataPage-&gt;data[slot.slotaddress],record,recordSize);
  
      free(dataPage);
      return 1;
  }
  </code></pre>
  
  <p><strong>After executing free(dataPage) i am getting the above error...</strong></p>
  
  <pre><code>typedef struct
  {
     int pagenumber;
     int priority;
     long dirPageNo;
     long cfs;
     int cfsptr;
     int slotcount;
     char data[1];
  } datapage;
  
  typedef struct
  {
     int slotaddress;
     int slotsize;
  } slotentry;
  </code></pre>
  
  <p>I had kept the free(dataPage) before the memcpy it's working fine but after memcpy it's not working.. and showing the error....Can any one help me from this issue...</p>