/* copies the data to the assigned slot */
errorCode copyData(limSizeCache * lsc, unsigned int slot, void * data){
  if (!ACCNT_DATA(lsc, slot)){
    /* we need to allocate data space */
    FCT_FAIL(pageAlloc(CACHE_BLOCK_SIZE, &(ACCNT_DATA(lsc, slot))), "insertNewElementNoDataCopy: CAn not allocate memory for data");  
  }

  memcpy(ACCNT_DATA(lsc, slot), data, CACHE_BLOCK_SIZE);
  
  return STATUS_OK;

}
Example #2
0
void* pgn::pageAlloc(size_t size, const char file[], int line)
{
	void* p = pageAlloc(size);

	if (heapAllocMap)
	{
		FileLine fileLine;
		fileLine.file = file;
		fileLine.line = line;
		(*heapAllocMap)[p] = fileLine;
	}

	return p;
}
/* Function that will be used by the cacheLookupFailedInsert() 
   It inserts an element, but does no data copying
   The access counter is updated
 */
errorCode insertNewElementNoDataCopy(limSizeCache * lsc, unsigned int slot, void * key, void ** address){
  updateAccessTime(lsc, slot);
  ACCNT_USED(lsc, slot) = 1;

  ACCNT_KEY(lsc, slot) = key;
  ACCNT_EVICT(lsc, slot) = 0;
  ACCNT_BH(lsc, slot) = NULL;

  if (ACCNT_DATA(lsc, slot) == NULL){
    /* we need to allocate data space */
   FCT_FAIL(pageAlloc(CACHE_BLOCK_SIZE, &(ACCNT_DATA(lsc, slot))), "insertNewElementNoDataCopy: CAn not allocate memory for data");
    
  }
  
  *address = ACCNT_DATA(lsc, slot);
  
  return STATUS_OK;
}