예제 #1
0
NA_EIDPROC
void NABasicObject::operator delete[](void* p)
{
#if 0
  if (p)	// "delete NULL;" is legal in C++, obviously a no-op
    {
      //NGG      CollHeap* h = ((NABasicObject*)p)->h_;
      NAHeap* h = (NAHeap *) ((NABasicObject*)p)->h_;

      // ComDEBUG(h != invalidHeapPtr());
      if (h == invalidHeapPtr())
        {
	  #ifndef NDEBUG
	  #ifndef __EID
	    cerr << "**WARNING: " << __FILE__ << ": "
	         << "Ignoring attempt to delete pointer twice    "
	         << "(possible memory leak at " << p << "; need to run Purify)"
		 << endl;
	  #endif
	  #endif
	  return;
	}

      ((NABasicObject*)p)->h_ = invalidHeapPtr();
      if (h)
	h->deallocateMemory(p);
      else
	{
	  //	  HEAPLOG_DELETE_ENTRY(p, NA_HEAP_BASIC)
	  ::operator delete(p);
	}
    }
#endif
	  ::operator delete(p);

}
예제 #2
0
// read and return procedure location table area (header + entries)
Int32
readPLTArea
(fstream              &mf,          // (IN) : binary module file
 module_header_struct &latestModHdr,// (IN) : its module header
 NAHeap               &heap,        // (IN) : allocate PLT area from here
 const char *     name,       // (IN) : module name (for error msg)
 ComDiagsArea         &diags,       // (IN) : deposit any error msg here
 plt_header_struct   *&pltArea)     // (OUT): plt header + entries
{
  // make sure we have reasonable arguments
  if (latestModHdr.plt_area_offset  <= 0 ||
      latestModHdr.plt_area_length  <= 0 ||
      latestModHdr.plt_hdr_length   <= 0 ||
      latestModHdr.plt_entry_length <= 0)
    return -1;

  // allocate space for PLT header
  plt_header_struct pltHdrCls, *latestPLTHdr, *plt;
  plt = (plt_header_struct *)
    heap.allocateMemory(latestModHdr.plt_hdr_length);

  // read procedure location table header
  mf.seekg(latestModHdr.plt_area_offset, ios::beg);
  mf.read((char *)plt, latestModHdr.plt_hdr_length);
  if (mf.fail()) {
    diags << DgSqlCode(-CLI_READ_ERROR) << DgString0(name);
    return -1;
  }
      
  // give versioning a chance to massage/migrate it to this version
  latestPLTHdr = (plt_header_struct*)plt->driveUnpack(plt, &pltHdrCls,NULL);
  if (!latestPLTHdr) {
    // error: version is no longer supported
    diags << DgSqlCode(-CLI_MOD_PLT_HDR_VERSION_ERROR) 
          << DgString0(name);
    return -1;
  }

  pltArea = latestPLTHdr;
  Int32 num_procs = latestPLTHdr->num_procedures;
  
  if (num_procs >= 1) {
	// allocate space for PLT header + entries
    heap.deallocateMemory(plt);
    plt = (plt_header_struct *)
      heap.allocateMemory((size_t)latestModHdr.plt_area_length);
	  
    // read procedure location table header + entries
    mf.seekg(latestModHdr.plt_area_offset, ios::beg);
    mf.read((char *)plt, (Int32)latestModHdr.plt_area_length);
    if (mf.fail()) {
      diags << DgSqlCode(-CLI_READ_ERROR) << DgString0(name);
      return -1;
    }
	  
    // give versioning a chance to massage/migrate it to this version
    latestPLTHdr = (plt_header_struct*)plt->driveUnpack(plt, &pltHdrCls, NULL);
    if (!latestPLTHdr) {
      // error: version is no longer supported
      diags << DgSqlCode(-CLI_MOD_PLT_HDR_VERSION_ERROR) 
            << DgString0(name);
      return -1;
    }
    pltArea = latestPLTHdr;
  }

  // verify its validity
  Lng32 errCode = pltArea->RtduStructIsCorrupt();
  if (errCode) {
    // the module file is corrupted or has invalid data
    diags << DgSqlCode(errCode) << DgString0(name);
    heap.deallocateMemory(plt);
    return -1;
  }
  return num_procs;
}