예제 #1
0
static void addMemTableEntry(void *memAlloc, size_t number, size_t size,
                             chpl_mem_descInt_t description, int32_t lineno,
                             int32_t filename) {
  unsigned hashValue;
  memTableEntry* memEntry;

  if ((totalEntries+1)*2 > hashSize && hashSizeIndex < NUM_HASH_SIZE_INDICES-1)
    resizeTable(1);

  memEntry = (memTableEntry*) sys_calloc(1, sizeof(memTableEntry));
  if (!memEntry) {
    chpl_error("memtrack fault: out of memory allocating memtrack table",
               lineno, filename);
  }

  hashValue = hash(memAlloc, hashSize);
  memEntry->nextInBucket = memTable[hashValue];
  memTable[hashValue] = memEntry;
  memEntry->description = description;
  memEntry->memAlloc = memAlloc;
  memEntry->lineno = lineno;
  memEntry->filename = filename;
  memEntry->number = number;
  memEntry->size = size;
  increaseMemStat(number*size, lineno, filename);
  totalEntries += 1;
}
예제 #2
0
static memTableEntry* removeMemTableEntry(void* address) {
  unsigned hashValue = hash(address, hashSize);
  memTableEntry* thisBucketEntry = memTable[hashValue];
  memTableEntry* deletedBucket = NULL;

  if (!thisBucketEntry)
    return NULL;

  if (thisBucketEntry->memAlloc == address) {
    memTable[hashValue] = thisBucketEntry->nextInBucket;
    deletedBucket = thisBucketEntry;
  } else {
    for (thisBucketEntry = memTable[hashValue];
         thisBucketEntry != NULL;
         thisBucketEntry = thisBucketEntry->nextInBucket) {

      memTableEntry* nextBucketEntry = thisBucketEntry->nextInBucket;

      if (nextBucketEntry && nextBucketEntry->memAlloc == address) {
        thisBucketEntry->nextInBucket = nextBucketEntry->nextInBucket;
        deletedBucket = nextBucketEntry;
      }
    }
  }
  if (deletedBucket) {
    decreaseMemStat(deletedBucket->number * deletedBucket->size);
    totalEntries -= 1;
    if (totalEntries*8 < hashSize && hashSizeIndex > 0)
      resizeTable(-1);
  }
  return deletedBucket;
}
예제 #3
0
void SCHashTable<K,V>::insert( K const & key, V const & value ) {
    if( (double)elems/size >= 0.7 )
        resizeTable();
    pair<K,V> p( key, value );
    int idx = hash( key, size );
    table[idx].push_front( p );
    elems++;
}
예제 #4
0
void LuaAVConsole :: showEvent(QShowEvent *event) {
	QList<int> sizes;	
	int h = mScriptSplitter->height() - mScriptSplitter->handleWidth();
	sizes.append(h-MIN_CODE_HEIGHT);
	sizes.append(MIN_CODE_HEIGHT);
	mScriptSplitter->setSizes(sizes);

	sizes.replace(0, 233);
	sizes.replace(1, 367);
	mSplitter->setSizes(sizes);

	resizeTable(mSplitter->sizes().at(0), 0);
}
예제 #5
0
void LuaAVConsole :: addScript(const char *name, const char *filename, luaav_state *S) {
	int idx = mScriptModel->getList().size();
	mScriptModel->insertRow(idx, QModelIndex());

	QModelIndex index = mScriptModel->index(idx, 0, QModelIndex());
	mScriptModel->setData(index, QString(name), Qt::EditRole);

	resizeTable(mSplitter->sizes().at(0), 0);

	// table buttons for script actions
	char bname[16];
	QPushButton *closeButton = new QPushButton();
	closeButton->setIcon(QIcon(QPixmap("/usr/share/luaav/x.png")));
	closeButton->setFlat(true);
	closeButton->setAutoFillBackground(true);
	sprintf(bname, "close:%d", mScriptsLoaded);
	closeButton->setObjectName(QString(bname));
	connect(closeButton, SIGNAL(clicked()), this, SLOT(fileAction()));
	mTableView->setIndexWidget(mScriptModel->index(idx, 1), closeButton);

	QPushButton *reloadButton = new QPushButton();
	reloadButton->setIcon(QIcon(QPixmap("/usr/share/luaav/reload.png")));
	reloadButton->setFlat(true);
	reloadButton->setAutoFillBackground(true);
	sprintf(bname, "reload:%d", mScriptsLoaded);	
	reloadButton->setObjectName(QString(bname));
	connect(reloadButton, SIGNAL(clicked()), this, SLOT(fileAction()));
	mTableView->setIndexWidget(mScriptModel->index(idx, 2), reloadButton);

	QPushButton *editButton = new QPushButton();
	editButton->setIcon(QIcon(QPixmap("/usr/share/luaav/eye.png")));
	editButton->setFlat(true);
	editButton->setAutoFillBackground(true);
	sprintf(bname, "edit:%d", mScriptsLoaded);
	editButton->setObjectName(QString(bname));
	connect(editButton, SIGNAL(clicked()), this, SLOT(fileAction()));
	mTableView->setIndexWidget(mScriptModel->index(idx, 3), editButton);

	mScripts.push_back(new ScriptData(mScriptsLoaded, name, filename, S));
	mScriptsLoaded++;
}
예제 #6
0
void LPHashTable<K,V>::insert( K const & key, V const & value ) {
    if ((double) elems/size>=.7 ) resizeTable();
    
    pair<K,V> *p= new pair<K,V>( key, value );
    int idx = hash( key, size );
    
    int i=0;
    while( i!=size ) 
    {
			if( table[idx] == NULL )
            {
            table[idx]=p;
            break;
            }
			idx = ( idx++)%size;
			i++;
    }

    elems++;
    
}
예제 #7
0
void LuaAVConsole :: resizeEvent(QResizeEvent *event) {
	resizeTable(mSplitter->sizes().at(0), 0);
}