ExFastExtractTcb::~ExFastExtractTcb()
{
  // Release resources acquired
  //
  freeResources();

  delete qParent_.up;
  delete qParent_.down;
 
  if (workAtp_)
  {
    workAtp_->release();
    deallocateAtp(workAtp_, getSpace());
  }

  if (inSqlBuffer_ && getHeap())
  {
    getHeap()->deallocateMemory(inSqlBuffer_);
    inSqlBuffer_ = NULL;
    childOutputTD_ = NULL;
  }
  if (sourceFieldsConvIndex_)
    getHeap()->deallocateMemory(sourceFieldsConvIndex_);

} // ExFastExtractTcb::~ExFastExtractTcb()
ExExeUtilTcb::~ExExeUtilTcb()
{
  delete qparent_.up;
  delete qparent_.down;
  if (workAtp_)
    {
      workAtp_->release();
      deallocateAtp(workAtp_, getGlobals()->getSpace());
      workAtp_ = NULL;
    }
  freeResources();

  if (extractedPartsObj_)
    {
      delete extractedPartsObj_;
      extractedPartsObj_ = NULL;
    }
  if (explQuery_)
    NADELETEBASIC(explQuery_, getHeap());
  if (childQueryId_ != NULL)
  {
    NADELETEBASIC(childQueryId_, getHeap());
    childQueryId_ = NULL;
    childQueryIdLen_ = 0;
  }
  if (outputBuf_ != NULL)
  {
    NADELETEBASIC(outputBuf_, getHeap());
    outputBuf_ = NULL;
    outputBuf_ = 0;
  }

};
void CmpMessageEnvs::unpackMyself(IpcMessageObjType objType,
				  IpcMessageObjVersion objVersion,
				  NABoolean sameEndianness,
				  IpcMessageObjSize objSize,
				  IpcConstMessageBufferPtr& buffer) 
{
  CmpMessageObj::unpackMyself(objType, objVersion, sameEndianness,
			      objSize, buffer);
  ::unpackBuffer(buffer, operator_);
  ::unpackBuffer(buffer, nEnvs_);
  if (nEnvs_)
  {
    envs_ = new(getHeap()) char*[nEnvs_];
    for (Int32 i=0; i < nEnvs_; i++) 
	{
	  envs_[i] = 0;
          unpackBuffer(buffer, envs_[i],getHeap());
	}
  }
  else
    envs_ = 0;

  unpackBuffer(buffer, cwd_, getHeap());
  ::unpackBuffer(buffer, activeTrans_);
  unpackBuffer(buffer, transId_);
}
void ExMsgResourceInfo::unpackObj(IpcMessageObjType objType,
				  IpcMessageObjVersion objVersion,
				  NABoolean sameEndianness,
				  IpcMessageObjSize objSize,
				  IpcConstMessageBufferPtr buffer)
{
  ExScratchFileOptions *sfo;
  IpcConstMessageBufferPtr start = buffer;

  ex_assert(objType == ESP_RESOURCE_INFO AND
	    objVersion == 100 AND
	    sameEndianness AND
	    objSize > sizeof(IpcMessageObj),
	    "invalid type or version for ExMsgResourceInfo::unpackObj()");
  unpackBaseClass(buffer);
  str_cpy_all((char *) &totalNameLength_,buffer,sizeof(totalNameLength_));
  buffer += sizeof(totalNameLength_);
  buffer += sizeof(spare_);
  if (bufferForDependentObjects_)
    {
      getHeap()->deallocateMemory(bufferForDependentObjects_);
      bufferForDependentObjects_ = NULL;
    }
  sfo = new(getHeap()) ExScratchFileOptions;

  // sfo_ is const
  sfo_ = sfo;

  sfo->ipcUnpackObj(objSize - (buffer-start),
		    buffer,
		    getHeap(),
		    totalNameLength_,
		    bufferForDependentObjects_);
}
void HdfsClient::setPath(const char *path)
{
   if (path_ != NULL) 
      NADELETEBASIC(path_, getHeap());
   short len = strlen(path);
   path_ = new (getHeap()) char[len+1];
   strcpy(path_, path); 
}
ExMsgFragment::~ExMsgFragment()
{
  if (f_.queryId_ != NULL)
    getHeap()->deallocateMemory(f_.queryId_);
  if (f_.userName_ != NULL)
    getHeap()->deallocateMemory(f_.userName_);
  if (f_.iOwnTheFragment_)
    getHeap()->deallocateMemory(fragment_);
}
void CmpMessageRequest::destroyMe()
{
   NADELETEBASIC(data_, getHeap());
   if (allocated_ && parentQid_ != NULL)
   {
     NADELETEBASIC(parentQid_, getHeap());
     parentQid_ = NULL;
     parentQidLen_ = 0;
   }
} 
// destructor. 
ExMsgSecurityInfo::~ExMsgSecurityInfo() 
{
  if (getHeap()) // members were allocated on this heap
  {
    getHeap()->deallocateMemory((void *)securityKey_);
    getHeap()->deallocateMemory(authid_);
    securityKey_ = NULL;
    authid_ = NULL;
  }
}
// The recipient of this object (connectionStream's actOnReceive) 
// will unpack this object in unbuffered stream, whose unpacking
// function would have already unpacked the base class before getting
// here. So, do not unpack the base class here. 
void ExMsgSecurityInfo::unpackObj(IpcMessageObjType objType,
                                  IpcMessageObjVersion objVersion,
                                  NABoolean sameEndianness,
		                  IpcMessageObjSize objSize,
				  IpcConstMessageBufferPtr buffer)
{
  buffer += sizeof(IpcMessageObj);
  unpackBuffer(buffer,securityKey_, getHeap());
  unpackBuffer(buffer,authid_, getHeap());
}
void CmpMessageISPRequest::destroyMe() 
{
  if (allocated_)
    {
      NADELETEBASIC(procName_, getHeap());
      NADELETEBASIC((char*)inputExpr_, getHeap());
      NADELETEBASIC((char*)outputExpr_, getHeap());
      NADELETEBASIC((char*)keyExpr_, getHeap());
      NADELETEBASIC((char*)inputData_, getHeap());
    }
}
void HdfsClient::deleteHdfsFileInfo()
{
   for (int i = 0; i < numFiles_ ; i ++) {
      NADELETEBASIC(hdfsFileInfo_[i].mName, getHeap());
      NADELETEBASIC(hdfsFileInfo_[i].mOwner, getHeap());
      NADELETEBASIC(hdfsFileInfo_[i].mGroup, getHeap());
   }
   if (hdfsFileInfo_ != NULL)
      NADELETEBASICARRAY(hdfsFileInfo_, getHeap()); 
   numFiles_ = 0;
   hdfsFileInfo_ = NULL;
}
Exemple #12
0
void tenkListChunks(PVOID heapHandle) {
	struct HPool			*heap;
	struct DestroyStruct	dStruct;
	struct HeapChunk		*curChunk;
	ULONG					i;

	heap = getHeap(&heapModel, heapHandle);
	dprintf("[T] Currently tracking %d chunks for heap 0x%08x\n", 
			heap->numChunks, heap->base);
	
	i = heap->inUseHead;
	while (i != NULLNODE) {
		if (CHUNK(i).inUse) {
			dprintf("\tAddress: 0x%08x\tSize: 0x%08x", CHUNK(i).addr, CHUNK(i).size);
			dprintf("\tFlags: 0x%08x\t%s\n\n", CHUNK(i).flags, 
					(CHUNK(i).free)?"FREE'D":"IN USE");
		}
		i = CHUNK(i).nextInUse;
	}

	if (heap->numChunks == 0) {
		dStruct.heapHandle	= heap->base;
		heapDestroy(&heapModel, &dStruct);
	}
}
HdfsClient::~HdfsClient()
{
   QRLogger::log(CAT_SQL_HDFS, LL_DEBUG, "HdfsClient::~HdfsClient() called.");
   deleteHdfsFileInfo();
   if (path_ != NULL) 
      NADELETEBASIC(path_, getHeap());
}
Exemple #14
0
static u32 sceHeapAllocHeapMemoryWithOption(u32 heapAddr, u32 memSize, u32 paramsPtr) {
	Heap *heap = getHeap(heapAddr);
	u32 grain = 4;
	if (!heap) {
		ERROR_LOG(HLE, "sceHeapAllocHeapMemoryWithOption(%08x, %08x, %08x): invalid heap", heapAddr, memSize, paramsPtr);
		return 0;
	}

	// 0 is ignored.
	if (paramsPtr != 0) {
		u32 size = Memory::Read_U32(paramsPtr);
		if (size < 8) {
			ERROR_LOG(HLE, "sceHeapAllocHeapMemoryWithOption(%08x, %08x, %08x): invalid param size", heapAddr, memSize, paramsPtr);
			return 0;
		}
		if (size > 8) {
			WARN_LOG_REPORT(HLE, "sceHeapAllocHeapMemoryWithOption(): unexpected param size %d", size);
		}
		grain = Memory::Read_U32(paramsPtr + 4);
	}

	DEBUG_LOG(HLE,"sceHeapAllocHeapMemoryWithOption(%08x, %08x, %08x)", heapAddr, memSize, paramsPtr);
	// There's 8 bytes at the end of every block, reserved.
	memSize += 8;
	u32 addr = heap->alloc.AllocAligned(memSize, grain, grain, true);
	return addr;
}
sp<IMemoryHeap> GPURegisterHeap::MemoryHeapRegs::GPUHandle::getMemory(
        ssize_t* offset, size_t* size) const
{
    sp<MemoryHeapPmem> heap = getHeap();
    if (offset) *offset = 0;
    if (size)   *size = heap !=0 ? heap->virtualSize() : 0;
    return heap;
}
Exemple #16
0
void tenkValidate(PVOID heapHandle) {
	struct HPool            *heap;
    struct DestroyStruct    dStruct;
    struct HeapChunk        *curChunk;
	ULONG					chunkPtr;
    ULONG                   i, nextIndex;
	BOOL					screwed = FALSE;

	heap = getHeap(&heapModel, heapHandle);

	i = heap->inUseHead;
	while (i != NULLNODE) {
		if (CHUNK(i).free) {
			// CHUNK(i).nextInUse must be equal to the next ptr
			if(!ReadMemory((ULONG64)(CHUNK(i).addr)+4, (PVOID) &chunkPtr, 4, NULL)) {
				dprintf("[T] Unable to read memory at address 0x%08x\n!");
				return;
			}

			// Find next free chunk - continue if there are no more
			nextIndex = CHUNK(i).nextInUse;
			while (nextIndex != NULLNODE && !(CHUNK(nextIndex).free))
				nextIndex = CHUNK(nextIndex).nextInUse;
			if (nextIndex == NULLNODE) {
				i = CHUNK(i).nextInUse;
				continue;
			}

			// Validate next free chunk
			if (CHUNK(nextIndex).addr != (PVOID) chunkPtr) {
				dprintf("[T] Corruped next pointer for chunk at 0x%08x\n", CHUNK(i).addr);
				dprintf(">\tGot: 0x%08x\tExpected: 0x%08x\n", chunkPtr, CHUNK(nextIndex).addr);
				screwed = TRUE;
			}
			
			// next free chunk prev, must equal CHUNK(i).addr
			if(!ReadMemory((ULONG64)CHUNK(nextIndex).addr, (PVOID) &chunkPtr, 4, NULL)) {
                dprintf("[T] Unable to read memory at address 0x%08x\n!");
                return; 
            }
			if ((PVOID) chunkPtr != CHUNK(i).addr) {
                dprintf("[T] Corruped prev pointer for chunk at 0x%08x\n", CHUNK(nextIndex).addr);
                dprintf(">\tGot: 0x%08x\tExpected: 0x%08x\n", chunkPtr, CHUNK(i).addr);
				screwed = TRUE;
			}
		
		
		} else {
		}
		i = CHUNK(i).nextInUse;
	}
	
	dprintf("[T] Validation complete: ");
	if (!screwed)
		dprintf("all known free chunks are correct\n");
	else
		dprintf("errors found\n");
}
void CmpMessageRequest::copyToString(char* &dest, CmpMsgBufLenType& sz,
				     char* source, CmpMsgBufLenType sz1) 
{
  NADELETEBASIC(dest, getHeap());
  if ( source ) 
    {
      sz = sz1 + 1;
      dest = new (getHeap()) char[sz];
#pragma nowarn(1506)   // warning elimination 
      str_cpy_all(dest, source, sz1);      
#pragma warn(1506)  // warning elimination 
      dest[sz1] = 0;
    }
  else
    {
      sz = 0;
      dest = 0;
    }
}
//
// This function frees any resources acquired.
// It should only be called by the TCB destructor.
//
void ExFastExtractTcb::freeResources()
{
  for(Int16 i=0; i < numBuffers_; i++)
  {
    if(bufferPool_[i])
    {
      NADELETE(bufferPool_[i], IOBuffer, getHeap());
      bufferPool_[i] = NULL;
    }
  }
}
HDFS_Client_RetCode HdfsClient::setHdfsFileInfo(JNIEnv *jenv, jint numFiles, jint fileNo, jboolean isDir, 
          jstring filename, jlong modTime, jlong len, jshort numReplicas, jlong blockSize, 
          jstring owner, jstring group, jshort permissions, jlong accessTime)
{
   HDFS_FileInfo *hdfsFileInfo;

   if (fileNo == 0 && hdfsFileInfo_ != NULL)
      deleteHdfsFileInfo();

   if (hdfsFileInfo_ == NULL) {
       hdfsFileInfo_ = new (getHeap()) HDFS_FileInfo[numFiles];
       numFiles_ = numFiles;
   }

   if (fileNo >= numFiles_)
      return HDFS_CLIENT_ERROR_SET_HDFSFILEINFO;
   hdfsFileInfo = &hdfsFileInfo_[fileNo];
   if (isDir)
      hdfsFileInfo->mKind = HDFS_DIRECTORY_KIND;
   else
      hdfsFileInfo->mKind = HDFS_FILE_KIND;
   hdfsFileInfo->mLastMod = modTime;
   hdfsFileInfo->mSize = len;  
   hdfsFileInfo->mReplication = numReplicas;
   hdfsFileInfo->mBlockSize = blockSize;
   hdfsFileInfo->mPermissions = permissions;
   hdfsFileInfo->mLastAccess = accessTime;
   jint tempLen = jenv->GetStringUTFLength(filename);
   hdfsFileInfo->mName = new (getHeap()) char[tempLen+1];   
   strncpy(hdfsFileInfo->mName, jenv->GetStringUTFChars(filename, NULL), tempLen);
   hdfsFileInfo->mName[tempLen] = '\0';
   tempLen = jenv->GetStringUTFLength(owner);
   hdfsFileInfo->mOwner = new (getHeap()) char[tempLen+1];   
   strncpy(hdfsFileInfo->mOwner, jenv->GetStringUTFChars(owner, NULL), tempLen);
   hdfsFileInfo->mOwner[tempLen] = '\0';
   tempLen = jenv->GetStringUTFLength(group);
   hdfsFileInfo->mGroup = new (getHeap()) char[tempLen+1];   
   strncpy(hdfsFileInfo->mGroup, jenv->GetStringUTFChars(group, NULL), tempLen);
   hdfsFileInfo->mGroup[tempLen] = '\0';
   return HDFS_CLIENT_OK;
}
Exemple #20
0
static int sceHeapDeleteHeap(u32 heapAddr) {
	Heap *heap = getHeap(heapAddr);
	if (!heap) {
		ERROR_LOG(HLE, "sceHeapDeleteHeap(%08x): invalid heap", heapAddr);
		return SCE_KERNEL_ERROR_INVALID_ID;
	}

	DEBUG_LOG(HLE, "sceHeapDeleteHeap(%08x)", heapAddr);
	heapList.erase(heapAddr);
	delete heap;
	return 0;
}
short ExExeUtilLongRunningTcb::finalizeDoLongRunning() 
{

  // Close the statements
  Lng32 rc = cliInterface()->prepareAndExecRowsEpilogue();

  NADELETE(initialOutputVarPtrList_, Queue, getHeap());
  NADELETE(continuingOutputVarPtrList_, Queue, getHeap());
  NADELETEBASIC(lruStmtAndPartInfo_, getHeap());
  NADELETEBASIC(lruStmtWithCKAndPartInfo_, getHeap());

  // if this is an ESP, deallocate transaction
  CliGlobals *cliGlobals = GetCliGlobals();
  if (cliGlobals->isESPProcess())
  {
     NADELETEBASIC(currTransaction_, getHeap());
     currTransaction_ = NULL;
  }

  return 0;
}
void CmpMessageISPRequest::unpackMyself(IpcMessageObjType objType,
					IpcMessageObjVersion objVersion,
					NABoolean sameEndianness,
					IpcMessageObjSize objSize,
					IpcConstMessageBufferPtr& buffer)
{
  allocated_ = TRUE; // so that the allocated storages will be destroyed later.
  CmpMessageRequest::unpackMyself(objType, objVersion, sameEndianness,
				  objSize, buffer);
  unpackBuffer(buffer, procName_, getHeap());
  ::unpackBuffer(buffer, inputExprSize_);
  unpackBuffer(buffer, inputExpr_, getHeap());
  ::unpackBuffer(buffer, outputExprSize_);
  unpackBuffer(buffer, outputExpr_, getHeap());
  ::unpackBuffer(buffer, keyExprSize_);
  unpackBuffer(buffer, keyExpr_, getHeap());
  ::unpackBuffer(buffer, inputDataSize_);
  unpackBuffer(buffer, inputData_, getHeap());
  ::unpackBuffer(buffer, outputRowSize_);
  ::unpackBuffer(buffer, outputTotalSize_);
}
void CmpMessageRequest::unpackMyself(IpcMessageObjType objType,
				     IpcMessageObjVersion objVersion,
				     NABoolean sameEndianness,
				     IpcMessageObjSize objSize,
				     IpcConstMessageBufferPtr& buffer)
{
  CmpMessageRequestBasic::unpackMyself(objType, objVersion, sameEndianness,
				       objSize, buffer);
  ::unpackBuffer(buffer, sz_);
  ::unpackBuffer(buffer, flags_);
  ::unpackBuffer(buffer, charSet_);
  unpackBuffer(buffer, data_, getHeap());
  ::unpackBuffer(buffer, parentQidLen_);
  if (parentQidLen_ != 0)
  {
    allocated_ = TRUE;
    parentQid_ = new ((NAHeap *)(getHeap())) char[parentQidLen_+1];
    unpackStrFromBuffer(buffer, (char *)parentQid_, parentQidLen_);
    *((char *)(parentQid_+ parentQidLen_)) = '\0';
  }
}
short ExExeUtilTcb::getObjectUid(char * catName, char * schName, 
				 char * objName, 
				 NABoolean isIndex, NABoolean isMv,
				 char* uid)
{
  Lng32 cliRC = 0;

  ex_queue_entry * pentry_down = qparent_.down->getHeadEntry();
  ExExeUtilPrivateState & pstate =
    *((ExExeUtilPrivateState*) pentry_down->pstate);

  ExExeStmtGlobals *exeGlob = getGlobals()->castToExExeStmtGlobals();
  ExMasterStmtGlobals *masterGlob = exeGlob->castToExMasterStmtGlobals();

  const QueryString * qs;
  Int32 sizeOfqs = 0;
  versionStrLen_ = 0;
  
  qs = getObjectUidQuery;
  sizeOfqs = sizeof(getObjectUidQuery);
  
  Int32 qryArraySize = sizeOfqs / sizeof(QueryString);
  char * gluedQuery;
  Lng32 gluedQuerySize;
  glueQueryFragments(qryArraySize,  qs,
		     gluedQuery, gluedQuerySize);
  
  Lng32 extraSpace = 10 /*segment name*/+ ComMAX_3_PART_EXTERNAL_UTF8_NAME_LEN_IN_BYTES/*cat/sch/obj name in UTF8*/ + 100;
  
  char * infoQuery =
    new(getHeap()) char[gluedQuerySize + extraSpace + 1];
  
  str_sprintf(infoQuery, gluedQuery,
	      catName, schName, objName, 
	      (isIndex ? "IX" : "TA"),
	      (isMv ? "MV" : (isIndex ? "IX" : "BT")));

  NADELETEBASIC(gluedQuery, getMyHeap());
  
  Lng32 uidLen;
  cliRC = 
    cliInterface()->executeImmediate(infoQuery, 
				     uid, &uidLen);
  if (cliRC < 0)
    {
      cliInterface()->retrieveSQLDiagnostics(getDiagsArea());
      return -1;
    }
  uid[uidLen] = 0;

  return 0;
}
ExHdfsFastExtractTcb::~ExHdfsFastExtractTcb()
{

  if (lobGlob_ != NULL)
  {
    lobGlob_ = NULL;
  }

  if (sequenceFileWriter_ != NULL) {
     NADELETE(sequenceFileWriter_, SequenceFileWriter, getHeap());
  }

} // ExHdfsFastExtractTcb::~ExHdfsFastExtractTcb()
void ExMsgTimeoutData::unpackObj(IpcMessageObjType objType,
				 IpcMessageObjVersion objVersion,
				 NABoolean sameEndianness,
				 IpcMessageObjSize objSize,
				 IpcConstMessageBufferPtr buffer)
{
  IpcConstMessageBufferPtr start = buffer;

  ex_assert(objType == ESP_TIMEOUT_DATA AND
	    objVersion == 100 AND
	    sameEndianness AND
	    objSize > sizeof(IpcMessageObj),
	    "invalid type or version for ExMsgTimeoutData::unpackObj()");

  unpackBaseClass(buffer);
  
  timeoutData_ = new ( getHeap() ) TimeoutData( getHeap() ) ;
  
  timeoutData_->unpackObj(buffer);

  iOwnTD_ = TRUE;  // on the ESP side; I own the newly allocated timeoutData_
}
short ExExeUtilHiveQueryTcb::work()
{
  short rc = 0;
  Lng32 cliRC = 0;
  if (qparent_.down->isEmpty())
    return WORK_OK;
  if (qparent_.up->isFull())
    return WORK_OK;
  ex_queue_entry * pentry_down = qparent_.down->getHeadEntry();
  ExExeUtilPrivateState & pstate = *((ExExeUtilPrivateState*) pentry_down->pstate);
  while (1)
    {
      switch (step_)
        {
        case INITIAL_:
          {
            step_ = PROCESS_QUERY_;
          }
          break;
        case PROCESS_QUERY_:
          {
            if (HiveClient_JNI::executeHiveSQL(htTdb().getHiveQuery()) != HVC_OK)
            {
                ExRaiseSqlError(getHeap(), &diagsArea_, -1214,
                        NULL, NULL, NULL,
                        getSqlJniErrorStr(), htTdb().getHiveQuery()); 
                step_ = ERROR_;
                break;
            }
            step_ = DONE_;
          }
          break;
        case ERROR_:
          {
            if (handleError())
              return WORK_OK;
            step_ = DONE_;
          }
          break;
        case DONE_:
          {
            if (handleDone())
              return WORK_OK;
            step_ = INITIAL_;
            return WORK_OK;
          }
          break;
        } // switch
    } // while
}
SeqGenEntry * SequenceValueGenerator::getEntry(SequenceGeneratorAttributes &sga)
{
  Int64 hashVal = sga.getSGObjectUID().get_value();

  sgQueue()->position((char*)&hashVal, sizeof(hashVal));

  SeqGenEntry * sge = NULL;
  while ((sge = (SeqGenEntry *)sgQueue()->getNext()) != NULL)
    {
      if (sge->getSGObjectUID() == hashVal)
	break;
    }

  if (! sge)
    {
      sge = new(getHeap()) SeqGenEntry(hashVal, getHeap());
      sgQueue()->insert((char*)&hashVal, sizeof(hashVal), sge);
    }

  sge->setRetryNum(getRetryNum());

  return sge;
}
Exemple #29
0
Allocation::~Allocation()
{
    size_t freedOffset = getOffset();
    size_t freedSize   = getSize();
    if (freedSize) {
        /* NOTE: it's VERY important to not free allocations of size 0 because
         * they're special as they don't have any record in the allocator
         * and could alias some real allocation (their offset is zero). */

        // keep the size to unmap in excess
        size_t pagesize = getpagesize();
        size_t start = freedOffset;
        size_t end = start + freedSize;
        start &= ~(pagesize-1);
        end = (end + pagesize-1) & ~(pagesize-1);

        // give back to the kernel the pages we don't need
        size_t free_start = freedOffset;
        size_t free_end = free_start + freedSize;
        if (start < free_start)
            start = free_start;
        if (end > free_end)
            end = free_end;
        start = (start + pagesize-1) & ~(pagesize-1);
        end &= ~(pagesize-1);

        if (start < end) {
            void* const start_ptr = (void*)(intptr_t(getHeap()->base()) + start);
            size_t size = end-start;

#ifndef NDEBUG
            memset(start_ptr, 0xdf, size);
#endif

            // MADV_REMOVE is not defined on Dapper based Goobuntu
#ifdef MADV_REMOVE
            if (size) {
                int err = madvise(start_ptr, size, MADV_REMOVE);
                ALOGW_IF(err, "madvise(%p, %u, MADV_REMOVE) returned %s",
                        start_ptr, size, err<0 ? strerror(errno) : "Ok");
            }
#endif
        }

        // This should be done after madvise(MADV_REMOVE), otherwise madvise()
        // might kick out the memory region that's allocated and/or written
        // right after the deallocation.
        mDealer->deallocate(freedOffset);
    }
}
Timer* TimerMinHeap::removeFromIndex (UINT32& index)
{
  // first, flip the top of the minheap with the bottom of the minheap, found in minheap [numberOfTimersBeingManaged]
  Timer** minheap = getHeap ();
  UINT32 parent = index;
  Timer* pTimer = minheap [parent];

  minheap [parent] = minheap [getNumberOfTimers () - 1]; // Disrupt the minheap property
  decNumberOfTimers ();
  downHeapifyFromIndex (index);

  COUT << "TimerMinHeap:: Removed item at index = " << index << endl;

  return pTimer;
}