void
JMemoryManager::EmptyStacks()
{
	if (itsMemoryTable != NULL && itsRecursionDepth == 0)
		{
		// Do alloc stack first so dealloc's never have to search through the
		// Alloc stack
		while (theAllocStackSize > 0)
			{
			theAllocStackSize--;
			JMMRecord thisRecord = theAllocStack[theAllocStackSize];

			AddNewRecord(thisRecord);
			}

		while (theDeallocStackSize > 0)
			{
			theDeallocStackSize--;
			DeleteRequest thisRequest = theDeallocStack[theDeallocStackSize];

			DeleteRecord(thisRequest.address, thisRequest.file,
						 thisRequest.line, thisRequest.array);
			}
		}
}
Example #2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QTextCodec *utfcodec = QTextCodec::codecForName("UTF-8");
    QTextCodec::setCodecForTr(utfcodec);
    QTextCodec::setCodecForCStrings(utfcodec);

    base = QSqlDatabase::addDatabase("QSQLITE"); //указываем тип базы

    ui->statusBar->addWidget(&stBar);

    connect(ui->tableView, SIGNAL(clicked(QModelIndex)), SLOT(TableRead(QModelIndex)));
    connect(ui->ButtonSave, SIGNAL(clicked()), SLOT(SaveBaseAll()));
    connect(ui->ButtonDelete, SIGNAL(clicked()), SLOT(DeleteRecord()));
    connect(ui->ButtonSearch, SIGNAL(clicked()), SLOT(Search()));
    connect(ui->ButtonDeleteFilter, SIGNAL(clicked()), SLOT(NoSearch()));
    connect(ui->ActionTruncate, SIGNAL(triggered()), SLOT(Truncate()));
    connect(ui->ButtonAddRecord, SIGNAL(clicked()), SLOT(AddRecord()));
    connect(ui->ActionNewBackup, SIGNAL(triggered()), SLOT(SaveBackup()));
    connect(ui->ActionLoadBackup, SIGNAL(triggered()), SLOT(LoadBackup()));
    connect(ui->AboutBase, SIGNAL(triggered()), SLOT(AboutBase()));
    connect(ui->ActionConvert, SIGNAL(triggered()), SLOT(ConvertFromOperaNotes()));
    connect(ui->ActionOpenBase, SIGNAL(triggered()), SLOT(OpenBase()));

    setAcceptDrops(true);
}
void
JMemoryManager::Delete
	(
	void*          block,
	const JBoolean isArray
	)
{
	if (theConstructingFlag || Instance()->itsRecursionDepth > 0)
		{
		DeleteRequest thisRequest;
		thisRequest.address = block;
		thisRequest.file    = itsLastDeleteFile;
		thisRequest.line    = itsLastDeleteLine;
		thisRequest.array   = isArray;

		assert(theDeallocStackSize < theStackMax);
		theDeallocStack[theDeallocStackSize] = thisRequest;
		theDeallocStackSize++;

		// Don't delete while on the request stack so that the MemoryTable entry
		// doesn't lie; is there a better way?
		}
	else
		{
		DeleteRecord(block, itsLastDeleteFile, itsLastDeleteLine, isArray);
		}

	itsLastDeleteFile = kUnknownFile;
	itsLastDeleteLine = 0;
}
Example #4
0
void DataModelListCtrlAdaptor::DeleteSelection(bool bDelete)
{
    wxArrayInt selections;
    m_listCtrl->GetRowSelections(selections);
    for (wxArrayInt::const_iterator it = selections.begin(); it != selections.end(); it++)
        DeleteRecord(*it, bDelete);
    m_listCtrl->Fill();
}
Example #5
0
/*----------------------------------------------------------------------------
>  Function Name: RtStatus_t FileRemove(int32_t RecordNumber,int32_t HandleNumber)

   FunctionType:  Reentrant

   Inputs:        1) Record Number
                  2) Handle Number  

   Outputs:       Returns SUCCESS on success else an Error Code 
                   
   Description:   Updates the handle to associate with the file to be deleted and
                  deletes the contents of the file i.e. marks all the clusters occupied by 
	              the file as zero in FAT Table.

<
----------------------------------------------------------------------------*/
RtStatus_t FileRemove(int32_t RecordNumber, int32_t HandleNumber)
{
    RtStatus_t RetValue = SUCCESS;
    uint8_t Buffer[32];
    int32_t ClusterNumber = 0, FileSize;
    HandleTable_t Temp;
    //  int64_t lTemp;

    Temp = Handle[HandleNumber];

    if (Handle[HandleNumber].StartingCluster != 0) {
        if ((RetValue = Fseek(HandleNumber, -DIRRECORDSIZE, SEEK_CUR)))
            return RetValue;
    }

    if (ReadDirectoryRecord(HandleNumber, RecordNumber, Buffer) < 0)
        return ERROR_OS_FILESYSTEM_NO_MATCHING_RECORD;

    if (Handle[HandleNumber].StartingCluster != 0) {
        if ((RetValue = Fseek(HandleNumber, -DIRRECORDSIZE, SEEK_CUR)))
            return RetValue;
    }

    if ((RetValue = DeleteRecord(HandleNumber, RecordNumber)) < 0)
        return RetValue;

    /* Set the Handle to original position */
    if ((RetValue = Fseek(HandleNumber, (RecordNumber * DIRRECORDSIZE), SEEK_SET)) < 0)
        return RetValue;

    FileSize = FSGetDWord(Buffer, DIR_FILESIZEOFFSET);

    // sdk2.6 changed this to left shift instead of right shift. 
    ClusterNumber =
        ((FSGetWord(Buffer, DIR_FSTCLUSLOOFFSET)) | (FSGetWord(Buffer, DIR_FSTCLUSHIOFFSET) << 16));

    if (((FSGetByte(Buffer, DIR_ATTRIBUTEOFFSET)) & DIRECTORY_MODE) == DIRECTORY_MODE)
        FileSize = 0x7fffffff;

    if ((ClusterNumber != 0) && (FileSize) != 0) {
        /* update the handle to associate with the file to be deleted */
        UpdateHandle(HandleNumber, ClusterNumber);

        /* Delete the contents of the file (i.e. Mark all the clusters occupied by 
           the file as zero in FAT Table) */
        if ((RetValue = DeleteContent(HandleNumber, 0)) < 0)
            return RetValue;
    }
    Handle[HandleNumber] = Temp;

    return SUCCESS;
}
	// clear all records
	void Untyped::Clear(void)
	{
		for (size_t slot = 0; slot < mCount; ++slot)
		{
			void *record = GetRecord(slot);
			DeleteRecord(record);
			mPool->Free(record);
		}
		memset(mMap, EMPTY, mLimit * 2 * sizeof(size_t));
		memset(mKey, 0, mLimit * sizeof(Key));
		memset(mData, 0, mLimit * sizeof(void *));
		mCount = 0;
	}
Example #7
0
INT32 CInvHead::Roll(UINT32 nDelDate, UINT32 strRefDate)
{
	
#ifdef PART_DEL
#endif
	
#ifndef PART_DEL
	
	//整段删除记录
	return (DeleteRecord(nDelDate));
	
#endif
	
}
// deletes the record and the object too and sets the pointer passed in to nil also catches
// the exception if the record was not found, since we were going to delete it anyway
void	//** Thread Safe **
ADataStore::DeleteRecord(CRecord* &inRecP) {
	ASSERT(inRecP != nil);
	DB_DEBUG("WriteRecord("<<inRecP->GetRecordID()<<")");
	Try_{
		DeleteRecord(inRecP->GetRecordID());
	}
	Catch_(err) {
		if (err != dbItemNotFound)
			Throw_(err);			// pass on the exception if it was something other than notFound
	}
	delete inRecP;
	inRecP = (CRecord*)nil;
}
Example #9
0
void CDBIOThread::Run()
{
    m_bQuit = false;
    while (!m_bQuit)
    {
        DBCmd cmd = GetDBCmd();
        switch (cmd.cmdType)
        {
        case INSERT_RECORD:
            InsertRecord(cmd);
            break;
        case DELETE_RECORD:
            DeleteRecord(cmd);
            break;
        case GET_RECORD:
            GetFirstRecord(cmd);
            break;
        default:
            break;
        }

        usleep(100*1000);
    }
}
Example #10
0
int main( void )
{
  FILE *FilePointer = OpenFile(FilePointer, 'w'); // Open file for writing
  Node* Head = malloc(sizeof(Node));

  BootStrapFile(FilePointer); // Create our base file
  fclose(FilePointer); // Close the file

  FilePointer = OpenFile(FilePointer, 'r'); // Reopen the file for reading
  ReadFile(FilePointer, Head); // Read file into linked lists
  PrintLinkedList( Head ); // Print the linked list
  fclose(FilePointer);
  FreeLinkedList(&Head);

  Head = (Node* )realloc(Head, sizeof(Node));
  FilePointer = OpenFile(FilePointer, 'r');
  ReadFile( FilePointer, Head );
  ManualEntry( Head );
  fclose(FilePointer);
  FilePointer = OpenFile(FilePointer, 'w'); // Reopen the file for reading

  WriteToFile( FilePointer, Head );
  fclose( FilePointer );
  FreeLinkedList( &Head );

  Head = (Node* )realloc(Head, sizeof(Node));
  FilePointer = OpenFile(FilePointer, 'r');
  ReadFile( FilePointer, Head );

  UpdateRecord( Head ); // Update record
  PrintLinkedList( Head );

  DeleteRecord( Head );
  PrintLinkedList( Head );

}
void main()
{
   int i;
   char s[128];
   struct ADDRESS address[MAX];/*定义结构体数组*/
   int num;/*保存记录数*/
   clrscr();  
   while(1)
   {
		   clrscr();
		   printf("********************MENU*******************\n\n");
		   printf("|      0: Input records                   |\n");
		   printf("|      1: List records in the file        |\n");
		   printf("|      2: Delete a record                 |\n");
		   printf("|      3: Insert a record to the list     |\n");
		   printf("|      4: Save records to the file        |\n");
		   printf("|      5: Load records from the file      |\n");
		   printf("|      6: Quit                            |\n\n");
		   printf("*******************************************\n");
		   do{
		      printf("\n	Input your choice(0~6):"); /*提示输入选项*/
		      scanf("%s",s); /*输入选择项*/
		      i=atoi(s); /*将输入的字符串转化为整型数*/
		   }while(i<0||i>6); /*选择项不在0~11之间重输*/
      switch(i)   /*调用主菜单函数,返回值整数作开关语句的条件*/
      {
				 case 0:num=InputRecord(address);break;/*输入记录*/
				 case 1:ListRecord(address,num);break; /*显示全部记录*/
				 case 2:num=DeleteRecord(address,num);break; /*删除记录*/
				 case 3:num=InsertRecord(address,num);  break;   /*插入记录*/
				 case 4:SaveRecord(address,num);break; /*保存文件*/
				 case 5:num=LoadRecord(address); break; /*读文件*/
				 case 6:exit(0); /*如返回值为11则程序结束*/
      }
   }
}
Example #12
0
void DataModelListCtrlAdaptor::DeleteAll(bool bDelete)
{
    for (unsigned int row = 0; row < (unsigned int)m_listCtrl->GetItemCount(); row++)
        DeleteRecord(row, bDelete);
    m_listCtrl->Fill();
}
Example #13
0
/**********************************************************************
* 函数名称: // ~CLogRecord()
* 功能描述: // 析构函数,释放资源,并删除log文件
* 输入参数: // 无
* 输出参数: // 无
* 返 回 值: // 无
* 其它说明: // 无
* -----------------------------------------------
* 2009/07/21	     V1.0
***********************************************************************/
CLogRecord::~CLogRecord()
{
	CloseLog();
	DeleteRecord();
}
Example #14
0
	// delete a record for a specified key
	void Untyped::Delete(Key aKey)
	{
		// convert key to a hash map index
		// (HACK: assume key is already a hash)
		size_t index = FindIndex(aKey);

		// if the slot is empty...
		size_t slot = mMap[index];
		if (slot == EMPTY)
		{
			// not found
			return;
		}

		// delete the record
		void *record = GetRecord(slot);
		DeleteRecord(record);
		mPool->Free(record);

		// update record count
		--mCount;

		// if not the last record...
		if (slot < mCount)
		{
			// move the last record into the vacant slot
			Key key = mKey[slot] = mKey[mCount];
			mData[slot] = mData[mCount];

			// update the map
			for (size_t keyindex = Index(key); mMap[keyindex] != EMPTY; keyindex = Next(keyindex))
			{
				if (mMap[keyindex] == mCount)
				{
					mMap[keyindex] = slot;
					break;
				}
			}
		}

		// clear the last record
		mData[mCount] = NULL;
		mKey[mCount] = 0;

		// for each entry in the cluster...
		size_t nextindex = index;
		while (1)
		{
			// get the next entry
			nextindex = Next(nextindex);
			size_t nextslot = mMap[nextindex];

			// stop upon reaching the end of the cluster
			if (nextslot == EMPTY)
				break;

			// if the entry is out of place, and there is a place for it...
			Key key = mKey[nextslot];
			size_t keyindex = Index(key);
			if ((nextindex > index && (keyindex <= index || keyindex > nextindex)) ||
				(nextindex < index && (keyindex <= index && keyindex > nextindex)))
			{
				// move the entry
				mMap[index] = mMap[nextindex];
				index = nextindex;
			}
		}

		// clear the empty slot
		mMap[index] = EMPTY;
	}
Example #15
0
void NcursesConsole(Connection *conn, const char *file)
{
	char console_buf[MAX_DATA];
	char *arg1, *arg2, *arg3, *arg4; 

	int *free_index = &(conn->core->cnf->free_index);
	int *delete_index = &(conn->core->cnf->delete_index);
	int *size = &(conn->core->cnf->size);

	wmove(console, 1, 1);
	touchwin(console);
	wrefresh(console);
	napms(100);
	wbkgd(border_console, COLOR_PAIR(5));
	touchwin(border_console);
	wrefresh(border_console);
	touchwin(console);
	wrefresh(console);
	echo();

	do {
		DisplayMode("Mode: Console");
		wmove(body, 0, 0);
		werase(body);
		DatabaseList(conn, body);
		PREFRESH;

		wgetnstr(console, console_buf, MAX_DATA);
		arg1 = strtok(console_buf, " ");
		arg2 = strtok(NULL, " ");
		arg3 = strtok(NULL, " ");
		arg4 = strtok(NULL, " ");

		ClearLine(console);

		if (arg1 != NULL) {

			if (strncmp(arg1, "add", 1) == 0) {
				if (arg4 == NULL) {
					if ((arg2 == NULL) || (arg3 == NULL)) {
						DisplayError("name or phone is empty\n");
					} else
						AddRecord(conn, NULL, arg2, arg3);
				} else {
					int i = atoi(arg2);
					if (i > *size || i < 0) {
						DisplayError("index out of bounds\n");
					} else {
						if ((arg3 == NULL) || (arg4 == NULL)) {
							DisplayError("name or phone is empty\n");
						} else {
							AddRecord(conn, &i, arg3, arg4);
						}
					}
				}
				DatabaseWrite(conn, file);
			}
			if (strncmp(arg1, "Insert", 1) == 0) {
				if (arg4 == NULL) {
					AddInsert(conn, NULL, arg2, arg3);
				} else {
					int i = atoi(arg2);
					if (i > *size || i < 0) {
						DisplayError("index out of bounds\n");
					} else {
						AddInsert(conn, &i, arg3, arg4);
					}
				}
				DatabaseWrite(conn, file);
			}
			if (strncmp(arg1, "delete", 1) == 0) {
				if (*free_index == 0 && *delete_index == 0) {
					DisplayError("database is already empty\n");
				} else if (arg2 == NULL) {
					DeleteRecord(conn, NULL);
				} else {
					int i = atoi(arg2);
					DeleteRecord(conn, &i);
				}
				DatabaseWrite(conn, file);
			}
			if (strncmp(arg1, "Delete", 1) == 0) {
				if (*free_index == 0 && *delete_index == 0) {
					DisplayError("database is already empty\n");
				} else if (arg2 == NULL) {
					DeleteInsert(conn, NULL);
				} else {
					int i = atoi(arg2);
					DeleteInsert(conn, &i);
				}
				DatabaseWrite(conn, file);
			}
			if (strncmp(arg1, "resize", 1) == 0) {
				int i = atoi(arg2);
				if (i == *size) {
					DisplayError("database size is already that size\n");
				} else if (i <= *free_index || i <= (*delete_index) + 1) {
					DisplayError("cannot resize below valid records\n");
				} else {
					DatabaseResize(conn, &i);
					DatabaseWrite(conn, file);
				}
			}
			if (strncmp(arg1, "Arrange", 1) == 0) {
				DatabaseArrange(conn);
				DatabaseWrite(conn, file);
			}
			if (strncmp(arg1, "sort", 1) == 0) {
				DatabaseSort(conn);
				DatabaseWrite(conn, file);
			}
			if (strncmp(arg1, "find", 1) == 0) {
				wmove(body, 0, 0);
				werase(body);
				DatabaseFind(conn, arg2, body);
				PREFRESH;
				getch();
			}
		} else
			break;
	} while (strncmp(arg1, "quit", 1) != 0);

	wbkgd(border_console, COLOR_PAIR(2));
	wrefresh(border_console);
	touchwin(console);
	wrefresh(console);
	noecho();
}
Example #16
0
void NcursesExamine(Connection *conn, const char *file)
{
	int y = 0, down = 0, selection = 0; 
	int input;
	char examine_buf[MAX_DATA];
	char *arg1, *arg2;

	struct Information *rows = conn->core->db->rows;

	int *free_index = &(conn->core->cnf->free_index);
	int *delete_index = &(conn->core->cnf->delete_index);
	int *size = &(conn->core->cnf->size);

	mvwprintw(body, 0, 0, "%-2d %-10s %-10s", rows[0].index,
			rows[0].name, rows[0].phone);

	do {
		DisplayMode("Mode: Examine");
		/* debug
		   getyx(body, gety, getx);

		   mvprintw(maxy - 10, maxx - 30, 
		   "\ny = %d\nx = %d\ndown = %d\n", y, x, down);
		   mvprintw(maxy - 7, maxx - 30, 
		   "\ngety = %d\ngetx = %d\n", gety, getx);
		   mvprintw(maxy - 10, maxx - 30, 
		   "\ny = %d\nx = %d\ndown = %d\n", y, x, down);
		   refresh();
		 */

		PREFRESH_SCROLL;

		input = getchar();

		switch(input) {

			case 'a':
				touchwin(add);
				wrefresh(add);
				echo();
				wmove(add, 1, 1);
				wrefresh(add);
				wgetnstr(add, examine_buf, MAX_DATA);
				arg1 = strtok(examine_buf, " ");
				arg2 = strtok(NULL, " ");
				if ((arg1 == NULL) || (arg2 == NULL)) {
					DisplayError("name or phone is empty\n");
				} else {
					AddRecord(conn, &selection, arg1, arg2);
					DatabaseWrite(conn, file);
				}
				noecho();
				ClearLine(add);
				RefreshdbList(conn);
				break;

			case 'I':
				touchwin(add);
				wrefresh(add);
				echo();
				wmove(add, 1, 1);
				wrefresh(add);
				wgetnstr(add, examine_buf, MAX_DATA);
				arg1 = strtok(examine_buf, " ");
				arg2 = strtok(NULL, " ");
				if (arg1) {
					AddInsert(conn, &selection, arg1, arg2);
					DatabaseWrite(conn, file);
				}
				noecho();
				ClearLine(add);
				RefreshdbList(conn);
				break;

			case 'd':
				DeleteRecord(conn, &selection);
				DatabaseWrite(conn, file);
				RefreshdbList(conn);
				break;

			case 'D':
				DeleteInsert(conn, &selection);
				DatabaseWrite(conn, file);
				RefreshdbList(conn);
				break;

			case 'f':
				touchwin(find);
				wrefresh(find);
				echo();
				wmove(find, 1, 1);
				wrefresh(find);
				wgetnstr(find, examine_buf, MAX_DATA);
				arg1 = strtok(examine_buf, " ");
				if (arg1) {
					wmove(body, 0, 0);
					werase(body);
					DatabaseFind(conn, arg1, body);
					PREFRESH_SCROLL;
					getch();
				}
				noecho();
				ClearLine(find);
				RefreshdbList(conn);
				break;


				//case KEY_DOWN:
			case 'j':
				if (y != (maxy / 2) + 3) y++;
				wmove(body, y, 0);
				selection++;
				RefreshdbList(conn);
				if (y == (maxy / 2) + 3) down++;
				if (selection > (*size) - 1) {
					selection = 0;
					y = 0;
					down = 0;
				}
				ExamineSelection(&selection, conn);
				break;

				//case KEY_UP:
			case 'k':
				if (y != 0) y--;
				selection--;
				RefreshdbList(conn);
				if ((y == 0) && (down != 0)) down--;
				if (selection < 0) {
					selection = (*size) - 1;
					y = (*size) / 2;
					down = (*size) / 2;
				}
				ExamineSelection(&selection, conn);
				break;

			case 'r':
				touchwin(resize);
				wrefresh(resize);
				echo();
				wmove(resize, 1, 1);
				wrefresh(resize);
				wgetnstr(resize, examine_buf, MAX_DATA);
				arg1 = strtok(examine_buf, " ");
				if (arg1) {
					int i = atoi(arg1);
					if (i == *size) {
						DisplayError("database size is already that size\n");
					} else if (i <= *free_index || i <= (*delete_index) + 1) {
						DisplayError("cannot resize below valid records\n");
					} else {
						DatabaseResize(conn, &i);
						DatabaseWrite(conn, file);
					}
				}
				noecho();
				ClearLine(resize);
				RefreshdbList(conn);
				break;

			case 'A':
				DatabaseArrange(conn);
				DatabaseWrite(conn, file);
				RefreshdbList(conn);
				break;

			case 's':
				DatabaseSort(conn);
				DatabaseWrite(conn, file);
				RefreshdbList(conn);
				break;

			default:
				break;
		}

	} while (input != 'q');

	RefreshdbList(conn);
	PREFRESH_SCROLL;
}
void EMFRecordEditorFrame::OnDeleteRecordClick( wxCommandEvent& event )
{
    wxArrayInt sel = GetSelectedItems();
    for (int i=0; i<sel.GetCount(); i++)
        DeleteRecord(sel[i]);
}
Example #18
0
int main(int argc, char *argv[]) {
  int i, j;
  int record_count = 400;
  int range = record_count/10;
  uint8_t len = 5;
  AttributeType type[len];
  const char hans[] = "hans";
  Index *index;
  Iterator **iterator = (Iterator**) malloc(sizeof(Iterator*));
  Transaction *t;
  Record recs[record_count];
  Key keys[record_count];
  Key minkey;
  Key maxkey;
  Record *currentResult;
  Attribute attr;
  Block blocks[record_count];
  time_t tm;
  
  for (j = 0; j < record_count; j++) {
    blocks[j].size = 5;
    blocks[j].data = malloc(5);
    sprintf((char*)blocks[j].data, "%i", j);
    attr.type = kInt;
    keys[j].value = (Attribute**) malloc(len*sizeof(Attribute*));
    keys[j].attribute_count = len;
//     printf("Key number %i: \n", j);
    for (i = 0; i < len; i++) {
      type[i] = kInt;
      keys[j].value[i] = (Attribute*) malloc(sizeof(Attribute));
      keys[j].value[i]->type = kInt;
      keys[j].value[i]->int_value = randInt(range);
//       printf("key.value[%i] = %ld \n", i, keys[j].value[i]->int_value);
    }
//     printf("\n");
    recs[j].key = keys[j];
    recs[j].payload = blocks[j];
  }
  // generate min and max keys
  minkey.value = (Attribute**) malloc(len*sizeof(Attribute*));
  minkey.attribute_count = len;
  maxkey.value = (Attribute**) malloc(len*sizeof(Attribute*));
  maxkey.attribute_count = len;
  for (i = 0; i < len; i++) {
    minkey.value[i] = (Attribute*) malloc(sizeof(Attribute));
    minkey.value[i]->type = kInt;
    minkey.value[i]->int_value = 0.3*range;
    maxkey.value[i] = (Attribute*) malloc(sizeof(Attribute));
    maxkey.value[i]->type = kInt;
    maxkey.value[i]->int_value = 0.8*range;
  }
  printf("Done with generating data. \n");
  
  tm = time(NULL);
  CreateIndex(hans, len, type); // len
  OpenIndex(hans, &index);
  BeginTransaction(&t);
  for (i = 0; i < record_count; i++) { //record_count
    InsertRecord(t, index, recs+i);
    if (i % 1000 == 0) 
      printf("i = %i / %i \n", i, record_count);
  }
  printf("finished inserting, took %is \n", time(NULL)-tm);
  tm = time(NULL);
//   for (i = 0; i < record_count; i+=2) { // record_count
//     if (i == 398) {
//       printf("deleting record %i \n", i);
//     }
    DeleteRecord(t, index, recs+4, 0);
//   }
//   if (DeleteRecord(t, index, recs+398, 0) != kErrorNotFound) {
//     printf(";_; \n ");
//   }
  printf("deleted half of the records, took %is \n", time(NULL)-tm);
  GetRecords(t, index, minkey, maxkey, iterator);
  while (GetNext(*iterator, &currentResult) != kErrorNotFound) {
    printf("%i \t(%i\t%i\t%i\t%i\t%i)\t%s \n", currentResult->key.value[0]->int_value, currentResult->key.value[0]->int_value, currentResult->key.value[1]->int_value, currentResult->key.value[2]->int_value, currentResult->key.value[3]->int_value, currentResult->key.value[4]->int_value, currentResult->payload.data);
  }
  printf("just to be sure: \n");
  for (i = 0; i < record_count; i++) {
    for (j = 0; j < len; j++) { // len
//       if (!(compareKeys(minkey, keys[i], j, true) <= 0 && compareKeys(keys[i], maxkey, j, true) < 0)) {
	if (!((minkey.value[j] == 0 || compareKeys(minkey, keys[i], j, true) <= 0) && (maxkey.value[j] == 0 || compareKeys(keys[i], maxkey, j, true) < 0))) {
	break;
      }
    }
    if (j == len) { // len
      printf("so: %i \n", keys[i].value[0]->int_value);
    }
  }
//   printf("committing \n");
  CommitTransaction(&t);
//   printf("closing \n");
  CloseIndex(&index);
//   printf("deleting \n");
  DeleteIndex(hans);
//   printf("should be zero: %i \n", all_indices["hans"]);
  return 0;
}