BOOL DOHexEditor::handleKey(KEY key, MASK mask, BOOL called_from_parent) { BOOL handled = FALSE; BOOL moved_cursor = FALSE; U32 old_cursor = mCursorPos; U32 cursor_line = mCursorPos / mColumns; U32 doc_first_line = 0; U32 doc_last_line = mValue.size() / mColumns; //U32 first_line = mScrollbar->getDocPos(); //U32 last_line = first_line + mScrollbar->getPageSize(); // don't -2 from scrollbar sizes U32 beginning_of_line = mCursorPos - (mCursorPos % mColumns); U32 end_of_line = beginning_of_line + mColumns - 1; handled = TRUE; switch( key ) { // Movement keys case KEY_UP: if(cursor_line > doc_first_line) { moveCursor(mCursorPos - mColumns, mSecondNibble); moved_cursor = TRUE; } break; case KEY_DOWN: if(cursor_line < doc_last_line) { moveCursor(mCursorPos + mColumns, mSecondNibble); moved_cursor = TRUE; } break; case KEY_LEFT: if(mCursorPos) { if(!mSecondNibble) moveCursor(mCursorPos - 1, FALSE); else moveCursor(mCursorPos, FALSE); moved_cursor = TRUE; } break; case KEY_RIGHT: moveCursor(mCursorPos + 1, FALSE); moved_cursor = TRUE; break; case KEY_PAGE_UP: mScrollbar->pageUp(1); break; case KEY_PAGE_DOWN: mScrollbar->pageDown(1); break; case KEY_HOME: if(mask & MASK_CONTROL) moveCursor(0, FALSE); else moveCursor(beginning_of_line, FALSE); moved_cursor = TRUE; break; case KEY_END: if(mask & MASK_CONTROL) moveCursor(mValue.size(), FALSE); else moveCursor(end_of_line, FALSE); moved_cursor = TRUE; break; // Special case KEY_INSERT: gKeyboard->toggleInsertMode(); break; case KEY_ESCAPE: gFocusMgr.releaseFocusIfNeeded(this); break; // Editing case KEY_BACKSPACE: if(mHasSelection) { U32 start = getProperSelectionStart(); U32 end = getProperSelectionEnd(); del(start, end - 1, TRUE); moveCursor(start, FALSE); } else if(mCursorPos && (!mSecondNibble)) { del(mCursorPos - 1, mCursorPos - 1, TRUE); moveCursor(mCursorPos - 1, FALSE); } break; case KEY_DELETE: if(mHasSelection) { U32 start = getProperSelectionStart(); U32 end = getProperSelectionEnd(); del(start, end - 1, TRUE); moveCursor(start, FALSE); } else if((mCursorPos != mValue.size()) && (!mSecondNibble)) { del(mCursorPos, mCursorPos, TRUE); } break; default: handled = FALSE; break; } if(moved_cursor) { // Selecting and deselecting if(mask & MASK_SHIFT) { if(!mHasSelection) mSelectionStart = old_cursor; mSelectionEnd = mCursorPos; } else { mSelectionStart = mCursorPos; mSelectionEnd = mCursorPos; } mHasSelection = mSelectionStart != mSelectionEnd; } return handled; }
sdilo() { sdi = 0; oport(); del(del_lo); }
~Ptr() { del(); }
void MainWindow::createActions() { newAction = new QAction(tr("&New"), this); newAction->setIcon(QIcon(":/images/new.png")); newAction->setShortcut(tr("Ctrl+N")); newAction->setStatusTip(tr("Create a new spreadsheet file")); connect(newAction, SIGNAL(triggered()), this, SLOT(newFile())); openAction = new QAction(tr("&Open..."), this); openAction->setIcon(QIcon(":/images/open.png")); openAction->setShortcut(tr("Ctrl+O")); openAction->setStatusTip(tr("Open an existing spreadsheet file")); connect(openAction, SIGNAL(triggered()), this, SLOT(open())); saveAction = new QAction(tr("&Save"), this); saveAction->setIcon(QIcon(":/images/save.png")); saveAction->setShortcut(tr("Ctrl+S")); saveAction->setStatusTip(tr("Save the spreadsheet to disk")); connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); saveAsAction = new QAction(tr("Save &As..."), this); saveAsAction->setStatusTip(tr("Save the spreadsheet under a new " "name")); connect(saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs())); for (int i = 0; i < MaxRecentFiles; ++i) { recentFileActions[i] = new QAction(this); recentFileActions[i]->setVisible(false); connect(recentFileActions[i], SIGNAL(triggered()), this, SLOT(openRecentFile())); } exitAction = new QAction(tr("E&xit"), this); exitAction->setShortcut(tr("Ctrl+Q")); exitAction->setStatusTip(tr("Exit the application")); connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); cutAction = new QAction(tr("Cu&t"), this); cutAction->setIcon(QIcon(":/images/cut.png")); cutAction->setShortcut(tr("Ctrl+X")); cutAction->setStatusTip(tr("Cut the current selection's contents " "to the clipboard")); connect(cutAction, SIGNAL(triggered()), spreadsheet, SLOT(cut())); copyAction = new QAction(tr("&Copy"), this); copyAction->setIcon(QIcon(":/images/copy.png")); copyAction->setShortcut(tr("Ctrl+C")); copyAction->setStatusTip(tr("Copy the current selection's contents " "to the clipboard")); connect(copyAction, SIGNAL(triggered()), spreadsheet, SLOT(copy())); pasteAction = new QAction(tr("&Paste"), this); pasteAction->setIcon(QIcon(":/images/paste.png")); pasteAction->setShortcut(tr("Ctrl+V")); pasteAction->setStatusTip(tr("Paste the clipboard's contents into " "the current selection")); connect(pasteAction, SIGNAL(triggered()), spreadsheet, SLOT(paste())); deleteAction = new QAction(tr("&Delete"), this); deleteAction->setShortcut(tr("Del")); deleteAction->setStatusTip(tr("Delete the current selection's " "contents")); connect(deleteAction, SIGNAL(triggered()), spreadsheet, SLOT(del())); selectRowAction = new QAction(tr("&Row"), this); selectRowAction->setStatusTip(tr("Select all the cells in the " "current row")); connect(selectRowAction, SIGNAL(triggered()), spreadsheet, SLOT(selectCurrentRow())); selectColumnAction = new QAction(tr("&Column"), this); selectColumnAction->setStatusTip(tr("Select all the cells in the " "current column")); connect(selectColumnAction, SIGNAL(triggered()), spreadsheet, SLOT(selectCurrentColumn())); selectAllAction = new QAction(tr("&All"), this); selectAllAction->setShortcut(tr("Ctrl+A")); selectAllAction->setStatusTip(tr("Select all the cells in the " "spreadsheet")); connect(selectAllAction, SIGNAL(triggered()), spreadsheet, SLOT(selectAll())); findAction = new QAction(tr("&Find..."), this); findAction->setIcon(QIcon(":/images/find.png")); findAction->setShortcut(tr("Ctrl+F")); findAction->setStatusTip(tr("Find a matching cell")); connect(findAction, SIGNAL(triggered()), this, SLOT(find())); goToCellAction = new QAction(tr("&Go to Cell..."), this); goToCellAction->setIcon(QIcon(":/images/gotocell.png")); goToCellAction->setShortcut(tr("F5")); goToCellAction->setStatusTip(tr("Go to the specified cell")); connect(goToCellAction, SIGNAL(triggered()), this, SLOT(goToCell())); recalculateAction = new QAction(tr("&Recalculate"), this); recalculateAction->setShortcut(tr("F9")); recalculateAction->setStatusTip(tr("Recalculate all the " "spreadsheet's formulas")); connect(recalculateAction, SIGNAL(triggered()), spreadsheet, SLOT(recalculate())); sortAction = new QAction(tr("&Sort..."), this); sortAction->setStatusTip(tr("Sort the selected cells or all the " "cells")); connect(sortAction, SIGNAL(triggered()), this, SLOT(sort())); showGridAction = new QAction(tr("&Show Grid"), this); showGridAction->setCheckable(true); showGridAction->setChecked(spreadsheet->showGrid()); showGridAction->setStatusTip(tr("Show or hide the spreadsheet's " "grid")); connect(showGridAction, SIGNAL(toggled(bool)), spreadsheet, SLOT(setShowGrid(bool))); #if QT_VERSION < 0x040102 // workaround for a QTableWidget bug in Qt 4.1.1 connect(showGridAction, SIGNAL(toggled(bool)), spreadsheet->viewport(), SLOT(update())); #endif autoRecalcAction = new QAction(tr("&Auto-Recalculate"), this); autoRecalcAction->setCheckable(true); autoRecalcAction->setChecked(spreadsheet->autoRecalculate()); autoRecalcAction->setStatusTip(tr("Switch auto-recalculation on or " "off")); connect(autoRecalcAction, SIGNAL(toggled(bool)), spreadsheet, SLOT(setAutoRecalculate(bool))); aboutAction = new QAction(tr("&About"), this); aboutAction->setStatusTip(tr("Show the application's About box")); connect(aboutAction, SIGNAL(triggered()), this, SLOT(about())); aboutQtAction = new QAction(tr("About &Qt"), this); aboutQtAction->setStatusTip(tr("Show the Qt library's About box")); connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); }
send_lo() { sclk = 1; oport(); del(del_hi); sclk = 0; oport(); del(del_lo); };
void bfs() { int i,j,x,y,nb,cost,len,res; Q vx; if(S==T) { printf("0\n"); return ; } size=0; tmp.cost=0; tmp.res=0; tmp.state=S; for(i=1;i<=n;i++) for(j=0;j<=C;j++) h[i][j]=INF; h[S][0]=0; insert(tmp); while(size) { tmp=del(); if(tmp.state==T) { printf("%d\n",tmp.cost); return ; } x=tmp.state; res=tmp.res; cost=tmp.cost; for(i=1;i+res<=C;i++) { vx.state=x; vx.cost=cost+i*p[x]; vx.res=i+res; if(vx.cost<h[vx.state][vx.res]) { h[vx.state][vx.res]=vx.cost; insert(vx); } } nb=first[x]; while(nb!=-1) { y=e[nb].y; len=e[nb].c; if(res>=len) { vx.state=y; vx.res=res-len; vx.cost=cost; if(vx.cost<h[vx.state][vx.res]) { h[vx.state][vx.res]=vx.cost; insert(vx); } } nb=e[nb].next; } } printf("impossible\n"); }
int main(int argc, char **argv) { char *shmname = NULL; void *shmptr = NULL; int i, scan_to; gint shmsize; wg_int rlock = 0; wg_int wlock = 0; /* look for commands in argv[1] or argv[2] */ if(argc < 3) scan_to = argc; else scan_to = 3; shmsize = 0; /* 0 size causes default size to be used */ /* 1st loop through, shmname is NULL for default. If * the first argument is not a recognizable command, it * is assumed to be the shmname and the next argument * is checked against known commands. */ for(i=1; i<scan_to; i++) { if (!strcmp(argv[i],"help") || !strcmp(argv[i],"-h")) { usage(argv[0]); exit(0); } if (!strcmp(argv[i],"version") || !strcmp(argv[i],"-v")) { wg_print_code_version(); exit(0); } if (!strcmp(argv[i],"free")) { /* free shared memory */ wg_delete_database(shmname); exit(0); } if(argc>(i+1) && !strcmp(argv[i],"import")){ wg_int err, minsize, maxsize; err = wg_check_dump(NULL, argv[i+1], &minsize, &maxsize); if(err) { fprintf(stderr, "Import failed.\n"); break; } shmptr=wg_attach_memsegment(shmname, minsize, maxsize, 1); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } /* Locking is handled internally by the dbdump.c functions */ err = wg_import_dump(shmptr,argv[i+1]); if(!err) printf("Database imported.\n"); else if(err<-1) fprintf(stderr, "Fatal error in wg_import_dump, db may have"\ " become corrupt\n"); else fprintf(stderr, "Import failed.\n"); break; } else if(argc>(i+1) && !strcmp(argv[i],"export")){ wg_int err; int flags = 0; if(argv[i+1][0] == '-') { flags = parse_flag(argv[++i]); if(argc<=(i+1)) { /* Filename argument missing */ usage(argv[0]); exit(1); } } shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } /* Locking is handled internally by the dbdump.c functions */ if(flags & FLAGS_FORCE) err = wg_dump_internal(shmptr,argv[i+1], 0); else err = wg_dump(shmptr,argv[i+1]); if(err<-1) fprintf(stderr, "Fatal error in wg_dump, db may have"\ " become corrupt\n"); else if(err) fprintf(stderr, "Export failed.\n"); break; } #ifdef USE_DBLOG else if(argc>(i+1) && !strcmp(argv[i],"replay")){ wg_int err; shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } WLOCK(shmptr, wlock); err = wg_replay_log(shmptr,argv[i+1]); WULOCK(shmptr, wlock); if(!err) printf("Log suggessfully imported from file.\n"); else if(err<-1) fprintf(stderr, "Fatal error when importing, database may have "\ "become corrupt\n"); else fprintf(stderr, "Failed to import log (database unmodified).\n"); break; } #endif else if(argc>(i+1) && !strcmp(argv[i],"exportcsv")){ shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } RLOCK(shmptr, wlock); wg_export_db_csv(shmptr,argv[i+1]); RULOCK(shmptr, wlock); break; } else if(argc>(i+1) && !strcmp(argv[i],"importcsv")){ wg_int err; shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } WLOCK(shmptr, wlock); err = wg_import_db_csv(shmptr,argv[i+1]); WULOCK(shmptr, wlock); if(!err) printf("Data imported from file.\n"); else if(err<-1) fprintf(stderr, "Fatal error when importing, data may be partially"\ " imported\n"); else fprintf(stderr, "Import failed.\n"); break; } #ifdef USE_REASONER else if(argc>(i+1) && !strcmp(argv[i],"importprolog")){ wg_int err; shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } err = wg_import_prolog_file(shmptr,argv[i+1]); if(!err) printf("Data imported from prolog file.\n"); else if(err<-1) fprintf(stderr, "Fatal error when importing, data may be partially"\ " imported\n"); else fprintf(stderr, "Import failed.\n"); break; } else if(argc>(i+1) && !strcmp(argv[i],"importotter")){ wg_int err; shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } err = wg_import_otter_file(shmptr,argv[i+1]); if(!err) printf("Data imported from otter file.\n"); else if(err<-1) fprintf(stderr, "Fatal error when importing otter file, data may be partially"\ " imported\n"); else fprintf(stderr, "Import failed.\n"); break; } else if(argc>i && !strcmp(argv[i],"runreasoner")){ wg_int err; shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } //printf("about to call wg_run_reasoner\n"); err = wg_run_reasoner(shmptr,argc,argv); //if(!err); //printf("wg_run_reasoner finished ok.\n"); //else //fprintf(stderr, "wg_run_reasoner finished with an error %d.\n",err); //break; break; } else if(argc>i && !strcmp(argv[i],"testreasoner")){ wg_int err; //printf("about to call wg_test_reasoner\n"); err = wg_test_reasoner(argc,argv); //if(!err); //printf("wg_test_reasoner finished ok.\n"); //else //fprintf(stderr, "wg_test_reasoner finished with an error %d.\n",err); //break; break; } #endif #ifdef HAVE_RAPTOR else if(argc>(i+2) && !strcmp(argv[i],"exportrdf")){ wg_int err; int pref_fields = atol(argv[i+1]); shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } printf("Exporting with %d prefix fields.\n", pref_fields); RLOCK(shmptr, wlock); err = wg_export_raptor_rdfxml_file(shmptr, pref_fields, argv[i+2]); RULOCK(shmptr, wlock); if(err) fprintf(stderr, "Export failed.\n"); break; } else if(argc>(i+3) && !strcmp(argv[i],"importrdf")){ wg_int err; int pref_fields = atol(argv[i+1]); int suff_fields = atol(argv[i+2]); shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } printf("Importing with %d prefix fields, %d suffix fields.\n,", pref_fields, suff_fields); WLOCK(shmptr, wlock); err = wg_import_raptor_file(shmptr, pref_fields, suff_fields, wg_rdfparse_default_callback, argv[i+3]); WULOCK(shmptr, wlock); if(!err) printf("Data imported from file.\n"); else if(err<-1) fprintf(stderr, "Fatal error when importing, data may be partially"\ " imported\n"); else fprintf(stderr, "Import failed.\n"); break; } #endif else if(!strcmp(argv[i],"test")) { /* This test function does it's own memory allocation. */ wg_run_tests(WG_TEST_QUICK, 2); break; } else if(!strcmp(argv[i],"fulltest")) { wg_run_tests(WG_TEST_FULL, 2); break; } else if(!strcmp(argv[i], "header")) { shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } RLOCK(shmptr, wlock); wg_show_db_memsegment_header(shmptr); RULOCK(shmptr, wlock); break; } #ifdef _WIN32 else if(!strcmp(argv[i],"server")) { if(argc>(i+1)) { shmsize = parse_shmsize(argv[i+1]); if(!shmsize) fprintf(stderr, "Failed to parse memory size, using default.\n"); } shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } printf("Press Ctrl-C to end and release the memory.\n"); while(_getch() != 3); break; } #else else if(!strcmp(argv[i],"create")) { if(argc>(i+1)) { shmsize = parse_shmsize(argv[i+1]); if(!shmsize) fprintf(stderr, "Failed to parse memory size, using default.\n"); } shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } break; } #endif else if(argc>(i+1) && !strcmp(argv[i], "fill")) { int rows = atol(argv[i+1]); if(!rows) { fprintf(stderr, "Invalid number of rows.\n"); exit(1); } shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } WLOCK(shmptr, wlock); if(argc > (i+2) && !strcmp(argv[i+2], "mix")) wg_genintdata_mix(shmptr, rows, TESTREC_SIZE); else if(argc > (i+2) && !strcmp(argv[i+2], "desc")) wg_genintdata_desc(shmptr, rows, TESTREC_SIZE); else wg_genintdata_asc(shmptr, rows, TESTREC_SIZE); WULOCK(shmptr, wlock); printf("Data inserted\n"); break; } else if(argc>(i+1) && !strcmp(argv[i],"select")) { int rows = atol(argv[i+1]); int from = 0; if(!rows) { fprintf(stderr, "Invalid number of rows.\n"); exit(1); } if(argc > (i+2)) from = atol(argv[i+2]); shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } RLOCK(shmptr, wlock); selectdata(shmptr, rows, from); RULOCK(shmptr, wlock); break; } else if(argc>(i+1) && !strcmp(argv[i],"add")) { int err; shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } WLOCK(shmptr, wlock); err = add_row(shmptr, argv+i+1, argc-i-1); WULOCK(shmptr, wlock); if(!err) printf("Row added.\n"); break; } else if(argc>(i+2) && !strcmp(argv[i],"del")) { shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } /* Delete works like query(), except deletes the matching rows */ del(shmptr, argv+i+1, argc-i-1); break; break; } else if(argc>(i+3) && !strcmp(argv[i],"query")) { shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } /* Query handles it's own locking */ query(shmptr, argv+i+1, argc-i-1); break; } else if(argc>i && !strcmp(argv[i],"addjson")){ wg_int err; shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } WLOCK(shmptr, wlock); /* the filename parameter is optional */ err = wg_parse_json_file(shmptr, (argc>(i+1) ? argv[i+1] : NULL)); WULOCK(shmptr, wlock); if(!err) printf("JSON document imported.\n"); else if(err<-1) fprintf(stderr, "Fatal error when importing, data may be partially"\ " imported\n"); else fprintf(stderr, "Import failed.\n"); break; } else if(argc>(i+1) && !strcmp(argv[i],"findjson")) { shmptr=wg_attach_database(shmname, shmsize); if(!shmptr) { fprintf(stderr, "Failed to attach to database.\n"); exit(1); } WLOCK(shmptr, wlock); findjson(shmptr, argv[i+1]); WULOCK(shmptr, wlock); break; } shmname = argv[1]; /* no match, assume shmname was given */ } if(i==scan_to) { /* loop completed normally ==> no commands found */ usage(argv[0]); } if(shmptr) { RULOCK(shmptr, rlock); WULOCK(shmptr, wlock); wg_detach_database(shmptr); } exit(0); }
GraphVolume::~GraphVolume() { del(); }
main( ) { struct node *root=NULL,*ptr; int choice,k; while(1) { printf("\n"); printf("1.Search\n"); printf("2.Insert\n"); printf("3.Delete\n"); printf("4.Preorder Traversal\n"); printf("5.Inorder Traversal\n"); printf("6.Postorder Traversal\n"); printf("7.Height of tree\n"); printf("8.Find minimum and maximum\n"); printf("9.Quit\n"); printf("Enter your choice : "); scanf("%d",&choice); switch(choice) { case 1: printf("Enter the key to be searched : "); scanf("%d",&k); ptr = search(root, k); if(ptr!=NULL) printf("Key found\n"); break; case 2: printf("Enter the key to be inserted : "); scanf("%d",&k); root = insert(root, k); break; case 3: printf("Enter the key to be deleted : "); scanf("%d",&k); root = del(root,k); break; case 4: preorder(root); break; case 5: inorder(root); break; case 6: postorder(root); break; case 7: printf("Height of tree is %d\n", height(root)); break; case 8: ptr = Min(root); if(ptr!=NULL) printf("Minimum key is %d\n", ptr->info ); ptr = Max(root); if(ptr!=NULL) printf("Maximum key is %d\n", ptr->info ); break; case 9: exit(1); default: printf("Wrong choice\n"); }/*End of switch */ }/*End of while */ }/*End of main( )*/
mpfx_manager::~mpfx_manager() { del(m_one); }
void mpfx_manager::reset(mpfx & n) { del(n); n.m_sign = false; n.m_sig_idx = 0; SASSERT(check(n)); }
BackupStoreRefCountDatabase::refcount_t HousekeepStoreAccount::DeleteFile( int64_t InDirectory, int64_t ObjectID, BackupStoreDirectory &rDirectory, const std::string &rDirectoryFilename, BackupStoreInfo& rBackupStoreInfo) { // Find the entry inside the directory bool wasDeleted = false; bool wasOldVersion = false; int64_t deletedFileSizeInBlocks = 0; // A pointer to an object which requires committing if the directory save goes OK std::auto_ptr<RaidFileWrite> padjustedEntry; // BLOCK { BackupStoreRefCountDatabase::refcount_t refs = mapNewRefs->GetRefCount(ObjectID); BackupStoreDirectory::Entry *pentry = rDirectory.FindEntryByID(ObjectID); if(pentry == 0) { BOX_ERROR("Housekeeping on account " << BOX_FORMAT_ACCOUNT(mAccountID) << " " "found error: object " << BOX_FORMAT_OBJECTID(ObjectID) << " " "not found in dir " << BOX_FORMAT_OBJECTID(InDirectory) << ", " "indicates logic error/corruption? Run " "bbstoreaccounts check <accid> fix"); mErrorCount++; return refs; } // Record the flags it's got set wasDeleted = pentry->IsDeleted(); wasOldVersion = pentry->IsOld(); // Check this should be deleted if(!wasDeleted && !wasOldVersion) { // Things changed since we were last around return refs; } // Record size deletedFileSizeInBlocks = pentry->GetSizeInBlocks(); if(refs > 1) { // Not safe to merge patches if someone else has a // reference to this object, so just remove the // directory entry and return. rDirectory.DeleteEntry(ObjectID); if(wasDeleted) { rBackupStoreInfo.AdjustNumDeletedFiles(-1); } if(wasOldVersion) { rBackupStoreInfo.AdjustNumOldFiles(-1); } mapNewRefs->RemoveReference(ObjectID); return refs - 1; } // If the entry is involved in a chain of patches, it needs to be handled // a bit more carefully. if(pentry->GetDependsNewer() != 0 && pentry->GetDependsOlder() == 0) { // This entry is a patch from a newer entry. Just need to update the info on that entry. BackupStoreDirectory::Entry *pnewer = rDirectory.FindEntryByID(pentry->GetDependsNewer()); if(pnewer == 0 || pnewer->GetDependsOlder() != ObjectID) { THROW_EXCEPTION(BackupStoreException, PatchChainInfoBadInDirectory); } // Change the info in the newer entry so that this no longer points to this entry pnewer->SetDependsOlder(0); } else if(pentry->GetDependsOlder() != 0) { BackupStoreDirectory::Entry *polder = rDirectory.FindEntryByID(pentry->GetDependsOlder()); if(pentry->GetDependsNewer() == 0) { // There exists an older version which depends on this one. Need to combine the two over that one. // Adjust the other entry in the directory if(polder == 0 || polder->GetDependsNewer() != ObjectID) { THROW_EXCEPTION(BackupStoreException, PatchChainInfoBadInDirectory); } // Change the info in the older entry so that this no longer points to this entry polder->SetDependsNewer(0); } else { // This entry is in the middle of a chain, and two patches need combining. // First, adjust the directory entries BackupStoreDirectory::Entry *pnewer = rDirectory.FindEntryByID(pentry->GetDependsNewer()); if(pnewer == 0 || pnewer->GetDependsOlder() != ObjectID || polder == 0 || polder->GetDependsNewer() != ObjectID) { THROW_EXCEPTION(BackupStoreException, PatchChainInfoBadInDirectory); } // Remove the middle entry from the linked list by simply using the values from this entry pnewer->SetDependsOlder(pentry->GetDependsOlder()); polder->SetDependsNewer(pentry->GetDependsNewer()); } // COMMON CODE to both cases // Generate the filename of the older version std::string objFilenameOlder; MakeObjectFilename(pentry->GetDependsOlder(), objFilenameOlder); // Open it twice (it's the diff) std::auto_ptr<RaidFileRead> pdiff(RaidFileRead::Open(mStoreDiscSet, objFilenameOlder)); std::auto_ptr<RaidFileRead> pdiff2(RaidFileRead::Open(mStoreDiscSet, objFilenameOlder)); // Open this file std::string objFilename; MakeObjectFilename(ObjectID, objFilename); std::auto_ptr<RaidFileRead> pobjectBeingDeleted(RaidFileRead::Open(mStoreDiscSet, objFilename)); // And open a write file to overwrite the other directory entry padjustedEntry.reset(new RaidFileWrite(mStoreDiscSet, objFilenameOlder, mapNewRefs->GetRefCount(ObjectID))); padjustedEntry->Open(true /* allow overwriting */); if(pentry->GetDependsNewer() == 0) { // There exists an older version which depends on this one. Need to combine the two over that one. BackupStoreFile::CombineFile(*pdiff, *pdiff2, *pobjectBeingDeleted, *padjustedEntry); } else { // This entry is in the middle of a chain, and two patches need combining. BackupStoreFile::CombineDiffs(*pobjectBeingDeleted, *pdiff, *pdiff2, *padjustedEntry); } // The file will be committed later when the directory is safely commited. // Work out the adjusted size int64_t newSize = padjustedEntry->GetDiscUsageInBlocks(); int64_t sizeDelta = newSize - polder->GetSizeInBlocks(); mBlocksUsedDelta += sizeDelta; if(polder->IsDeleted()) { mBlocksInDeletedFilesDelta += sizeDelta; } if(polder->IsOld()) { mBlocksInOldFilesDelta += sizeDelta; } polder->SetSizeInBlocks(newSize); } // pentry no longer valid } // Delete it from the directory rDirectory.DeleteEntry(ObjectID); // Save directory back to disc // BLOCK { RaidFileWrite writeDir(mStoreDiscSet, rDirectoryFilename, mapNewRefs->GetRefCount(InDirectory)); writeDir.Open(true /* allow overwriting */); rDirectory.WriteToStream(writeDir); // Get the disc usage (must do this before commiting it) int64_t new_size = writeDir.GetDiscUsageInBlocks(); // Commit directory writeDir.Commit(BACKUP_STORE_CONVERT_TO_RAID_IMMEDIATELY); // Adjust block counts if the directory itself changed in size int64_t original_size = rDirectory.GetUserInfo1_SizeInBlocks(); int64_t adjust = new_size - original_size; mBlocksUsedDelta += adjust; mBlocksInDirectoriesDelta += adjust; UpdateDirectorySize(rDirectory, new_size); } // Commit any new adjusted entry if(padjustedEntry.get() != 0) { padjustedEntry->Commit(BACKUP_STORE_CONVERT_TO_RAID_IMMEDIATELY); padjustedEntry.reset(); // delete it now } // Drop reference count by one. Must now be zero, to delete the file. bool remaining_refs = mapNewRefs->RemoveReference(ObjectID); ASSERT(!remaining_refs); // Delete from disc BOX_TRACE("Removing unreferenced object " << BOX_FORMAT_OBJECTID(ObjectID)); std::string objFilename; MakeObjectFilename(ObjectID, objFilename); RaidFileWrite del(mStoreDiscSet, objFilename, mapNewRefs->GetRefCount(ObjectID)); del.Delete(); // Adjust counts for the file ++mFilesDeleted; mBlocksUsedDelta -= deletedFileSizeInBlocks; if(wasDeleted) { mBlocksInDeletedFilesDelta -= deletedFileSizeInBlocks; rBackupStoreInfo.AdjustNumDeletedFiles(-1); } if(wasOldVersion) { mBlocksInOldFilesDelta -= deletedFileSizeInBlocks; rBackupStoreInfo.AdjustNumOldFiles(-1); } // Delete the directory? // Do this if... dir has zero entries, and is marked as deleted in it's containing directory if(rDirectory.GetNumberOfEntries() == 0) { // Candidate for deletion mEmptyDirectories.push_back(InDirectory); } return 0; }
void HousekeepStoreAccount::DeleteEmptyDirectory(int64_t dirId, std::vector<int64_t>& rToExamine, BackupStoreInfo& rBackupStoreInfo) { // Load up the directory to potentially delete std::string dirFilename; BackupStoreDirectory dir; int64_t dirSizeInBlocks = 0; // BLOCK { MakeObjectFilename(dirId, dirFilename); // Check it actually exists (just in case it gets // added twice to the list) if(!RaidFileRead::FileExists(mStoreDiscSet, dirFilename)) { // doesn't exist, next! return; } // load std::auto_ptr<RaidFileRead> dirStream( RaidFileRead::Open(mStoreDiscSet, dirFilename)); dirSizeInBlocks = dirStream->GetDiscUsageInBlocks(); dir.ReadFromStream(*dirStream, IOStream::TimeOutInfinite); } // Make sure this directory is actually empty if(dir.GetNumberOfEntries() != 0) { // Not actually empty, try next one return; } // Candidate for deletion... open containing directory std::string containingDirFilename; BackupStoreDirectory containingDir; int64_t containingDirSizeInBlocksOrig = 0; { MakeObjectFilename(dir.GetContainerID(), containingDirFilename); std::auto_ptr<RaidFileRead> containingDirStream( RaidFileRead::Open(mStoreDiscSet, containingDirFilename)); containingDirSizeInBlocksOrig = containingDirStream->GetDiscUsageInBlocks(); containingDir.ReadFromStream(*containingDirStream, IOStream::TimeOutInfinite); containingDir.SetUserInfo1_SizeInBlocks(containingDirSizeInBlocksOrig); } // Find the entry BackupStoreDirectory::Entry *pdirentry = containingDir.FindEntryByID(dir.GetObjectID()); // TODO FIXME invert test and reduce indentation if((pdirentry != 0) && pdirentry->IsDeleted()) { // Should be deleted containingDir.DeleteEntry(dir.GetObjectID()); // Is the containing dir now a candidate for deletion? if(containingDir.GetNumberOfEntries() == 0) { rToExamine.push_back(containingDir.GetObjectID()); } // Write revised parent directory RaidFileWrite writeDir(mStoreDiscSet, containingDirFilename, mapNewRefs->GetRefCount(containingDir.GetObjectID())); writeDir.Open(true /* allow overwriting */); containingDir.WriteToStream(writeDir); // get the disc usage (must do this before commiting it) int64_t dirSize = writeDir.GetDiscUsageInBlocks(); // Commit directory writeDir.Commit(BACKUP_STORE_CONVERT_TO_RAID_IMMEDIATELY); UpdateDirectorySize(containingDir, dirSize); // adjust usage counts for this directory if(dirSize > 0) { int64_t adjust = dirSize - containingDirSizeInBlocksOrig; mBlocksUsedDelta += adjust; mBlocksInDirectoriesDelta += adjust; } if (mapNewRefs->RemoveReference(dir.GetObjectID())) { // Still referenced BOX_TRACE("Housekeeping spared empty deleted dir " << BOX_FORMAT_OBJECTID(dirId) << " due to " << mapNewRefs->GetRefCount(dir.GetObjectID()) << "remaining references"); return; } // Delete the directory itself BOX_INFO("Housekeeping removing empty deleted dir " << BOX_FORMAT_OBJECTID(dirId)); RaidFileWrite del(mStoreDiscSet, dirFilename, mapNewRefs->GetRefCount(dir.GetObjectID())); del.Delete(); // And adjust usage counts for the directory that's // just been deleted mBlocksUsedDelta -= dirSizeInBlocks; mBlocksInDirectoriesDelta -= dirSizeInBlocks; // Update count ++mEmptyDirectoriesDeleted; rBackupStoreInfo.AdjustNumDirectories(-1); } }
points::~points() { del(); }
void ft_lstdelone(t_list **alst, void (*del)(void *, size_t)) { del((*alst)->content, (*alst)->content_size); free(*alst); *alst = NULL; }
int main(void) { char c; int i, num; node* ptr = first; printf("How many entries do you want to enter initially?\n"); // ask user for a initial list length scanf("%i", &num); // create user defined length of a list of structures for (i = 0; i < num ; i++) { ptr = insert(ptr); } do { printf("Currently you have %i entry(ies)", num_list); if (num_list > 0) { if (ptr != NULL) { print_current(ptr); } } // print instructions printf("\nMENU\n\n" "1 - delete\n" "2 - insert\n" "3 - search\n" "4 - print_list\n" "5 - move to the previous list\n" "6 - move to the next list\n" "0 - quit\n\n"); // get command printf("Command: "); fflush(stdin); scanf("%c", &c); // try to execute command switch (c) { case '1': del(); break; case '2': ptr = insert(ptr); break; case '3': search(); break; case '4': print_list(); break; case '5': ptr = move_pred(ptr); break; case '6': ptr = move_next(ptr); break; } } while (c != '0'); // free list before quitting(to prevent memory leakage) while (ptr != NULL) { node* predptr = ptr; ptr = ptr->next; if (predptr->person != NULL) { if (predptr->person->name != NULL) { free(predptr->person->name); } free(predptr->person); } free(predptr); } }
status LsmLevelMemory::del(node *r, dtype x) { if (r == NULL) return NotFound; int i, j, pivot, n = r->n; dtype *k = r->k; // k[i] means r->k[i] const int nMin = (M - 1)/2; status code; node **p = r->p, *pL, *pR; // p[i] means r->p[i] i = NodeSearch(x, k, n); if (p[0] == NULL) // *r is a leaf { if (i == n || x < k[i]) return NotFound; // x == k[i], and *r is a leaf for (j=i+1; j < n; j++) { k[j-1] = k[j]; p[j] = p[j+1]; } return --r->n >= (r==root ? 1 : nMin) ? Success : Underflow; } // *r is an interior node, not a leaf: if (i < n && x == k[i]) { // x found in an interior node. Go to left child // *p[i] and follow a path all the way to a leaf, // using rightmost branches: node *q = p[i], *q1; int nq; for (;;) { nq = q->n; q1 = q->p[nq]; if (q1 == NULL) break; q = q1; } // Exchange k[i] (= x) with rightmost item in leaf: k[i] = q->k[nq-1]; q->k[nq - 1] = x; } // Delete x in leaf of subtree with root p[i]: code = del(p[i], x); if (code != Underflow) return code; // There is underflow; borrow, and, if necessary, merge: // Too few data items in node *p[i] if (i > 0 && p[i-1]->n > nMin) // Borrow from left sibling { pivot = i - 1; // k[pivot] between pL and pR: pL = p[pivot]; pR = p[i]; // Increase contents of *pR, borrowing from *pL: pR->p[pR->n + 1] = pR->p[pR->n]; for (j=pR->n; j>0; j--) { pR->k[j] = pR->k[j-1]; pR->p[j] = pR->p[j-1]; } pR->n++; pR->k[0] = k[pivot]; pR->p[0] = pL->p[pL->n]; k[pivot] = pL->k[--pL->n]; return Success; } if (i<n && p[i+1]->n > nMin) // Borrow from right sibling { pivot = i; // k[pivot] between pL and pR: pL = p[pivot]; pR = p[pivot+1]; // Increase contents of *pL, borrowing from *pR: pL->k[pL->n] = k[pivot]; pL->p[pL->n + 1] = pR->p[0]; k[pivot] = pR->k[0]; pL->n++; pR->n--; for (j=0; j < pR->n; j++) { pR->k[j] = pR->k[j+1]; pR->p[j] = pR->p[j+1]; } pR->p[pR->n] = pR->p[pR->n + 1]; return Success; } // Merge; neither borrow left nor borrow right possible. pivot = (i == n ? i - 1 : i); pL = p[pivot]; pR = p[pivot+1]; // Add k[pivot] and *pR to *pL: pL->k[pL->n] = k[pivot]; pL->p[pL->n + 1] = pR->p[0]; for (j=0; j < pR->n; j++) { pL->k[pL->n + 1 + j] = pR->k[j]; pL->p[pL->n + 2 + j] = pR->p[j+1]; } pL->n += 1 + pR->n; delete pR; for (j=i+1; j < n; j++) { k[j-1] = k[j]; p[j] = p[j+1]; } return --r->n >= (r == root ? 1 : nMin) ? Success : Underflow; }
int main() { struct bst *T; T=NULL; int ch; do { printf("\n\n \t\t\tBINARY SEARCH TREE\n"); printf("\n1.Insert\n2.Delete\n3.Display\n4.Find min\n5.Find max\n6.Find\n7.Exit\nEnter your choice : "); scanf("%d",&ch); switch(ch) { case 1: { struct bst *temp; temp=(struct bst*)malloc(sizeof(struct bst)); printf("\nEnter data to be inserted : "); scanf("%d",&temp->data); temp->left=NULL; temp->right=NULL; T=insert(T,temp); break; } case 2: { int data; printf("\nEnter data to be deleted : "); scanf("%d",&data); T=del(T,data); if(T==NULL)printf("\nEmpty tree"); break; } case 3: { printf("\n1.Inorder traversal\n2.Preorder traversal\n3.Postorder traversal\nEnter choice : "); scanf("%d",&ch); switch(ch) { case 1: inorder(T); break; case 2: preorder(T); break; case 3: postorder(T); break; default:break; } break; } case 4: { struct bst *min; min=find_min(T); if(min==NULL)printf("\nEmpty tree!!"); else printf("\nThe minimum value is %d",min->data); break; } case 5: { struct bst *max; max=find_max(T); if(max==NULL)printf("\nEmpty tree!!"); else printf("\nThe maximum value is %d",max->data); break; } case 6: { int data; struct bst *fd; printf("\nEnter data to be searched : "); scanf("%d",&data); fd=find(T,data); if(fd==NULL) printf("\nData not found!!"); else printf("\n%d is found in the tree",fd->data); break; } case 7: return 0; default: printf("\n Wrong choice!!"); } }while(5); }
void WinGroups::del(const ustring& name) { iterator it = find(name); if (it != end()) del(it); }
int main() { //创建单链表, 并且初始化 List list; list.head = NULL; list.tail = NULL; list.cnt = 0; printf("%s\n", empty(&list) ? "空" : "没空"); printf("%s\n", full(&list) ? "满" : "没满"); printf("链表中有%d个元素\n", size(&list)); printf("----------------\n"); push_head(&list, 11); travel(&list); push_head(&list, 22); travel(&list); push_head(&list, 33); travel(&list); printf("链表中有%d个元素\n", size(&list)); printf("----------------\n"); push_tail(&list, 44); travel(&list); push_tail(&list, 55); travel(&list); push_tail(&list, 66); travel(&list); printf("链表中有%d个元素\n", size(&list)); printf("----------------\n"); insert(&list, 77, -2); printf("链表中有%d个元素\n", size(&list)); travel(&list); insert(&list, 88, 0); printf("链表中有%d个元素\n", size(&list)); travel(&list); insert(&list, 99, 5); printf("链表中有%d个元素\n", size(&list)); travel(&list); insert(&list, 100, 2); printf("链表中有%d个元素\n", size(&list)); travel(&list); printf("--------------------\n"); printf("头节点元素值: %d\n", get_head(&list)); printf("尾节点元素值: %d\n", get_tail(&list)); printf("--------------------\n"); pop_head(&list); printf("链表中有%d个元素\n", size(&list)); printf("头节点元素值: %d\n", get_head(&list)); printf("尾节点元素值: %d\n", get_tail(&list)); printf("--------------------\n"); pop_tail(&list); printf("链表中有%d个元素\n", size(&list)); printf("头节点元素值: %d\n", get_head(&list)); printf("尾节点元素值: %d\n", get_tail(&list)); printf("--------------------\n"); del(&list, -2); travel(&list); del(&list, 0); travel(&list); del(&list, 4); travel(&list); del(&list, 1); travel(&list); del(&list, 2); travel(&list); del(&list, 7); travel(&list); printf("--------------------\n"); reverse_list(&list); printf("链表中有%d个元素\n", size(&list)); printf("头节点元素值: %d\n", get_head(&list)); printf("尾节点元素值: %d\n", get_tail(&list)); travel(&list); printf("--------------------\n"); reverse_travel_list(&list); printf("=====清空========\n"); clear(&list); return 0; }
int main(void) { stos *stos; int liczba; int flaga=1; int wym; printf("podaj maksymalna ilosc elementow stosu: "); scanf_s("%d", &wym); stos=makenull(wym); while(flaga==1) { switch(menu()) { case 1: printf("MENU:\t1 - Push\n\n"); printf("podaj liczbe: "); scanf_s("%d", &liczba); if(full(stos)) printf("stos jest pelny\n"); else { push(stos, liczba); printf("umieszczono na stosie\n"); } break; case 2: printf("MENU:\t2 - Pop\n\n"); if(empty(stos)) printf("stos jest pusty\n"); else printf("twoja liczba to: %d\n", pop(stos)); break; case 3: printf("MENU:\t3 - Pokaz top\n\n"); if(empty(stos)) printf("stos jest pusty\n"); else printf("liczba z top to: %d\n", top(stos)); break; case 4: printf("MENU:\t4 - Wydrukuj ca³y stos\n\n"); print(stos); break; case 5: printf("MENU:\t5 - Liczba elementow stosu\n"); if(empty(stos)) printf("stos jest pusty\n"); else printf("%d", size(stos)); break; case 6: printf("MENU:\t6 - Wyczysc stos\n\n"); printf("stos wysczyszczony\n"); clear(stos); break; case 0: printf("MENU:\t0 - Wyjscie\n\n"); printf("ZAMYKANIE...\npamiec po stosie zostanie zwolniona\n"); flaga=0; break; default: printf("blad, sproboj ponownie\n"); break; } printf("\n> > > potwierdz enterem < < <\n"); fflush(stdin); getchar(); system("cls"); } del(stos); return 0; }
void TreeView::slotDropped (QDropEvent * e, Q3ListViewItem *parent, Q3ListViewItem*after) { if(!e) return; // get destination folder TreeItem *parentItem = static_cast<TreeItem*>(parent); QString folder = parentItem ? parentItem->directory() : QString(); MenuFolderInfo *parentFolderInfo = parentItem ? parentItem->folderInfo() : m_rootFolder; if (e->source() != this) { // External drop KUrl::List urls; if (!K3URLDrag::decode(e, urls) || (urls.count() != 1) || !urls[0].isLocalFile()) return; QString path = urls[0].path(); if (!path.endsWith(".desktop")) return; QString menuId; QString result = createDesktopFile(path, &menuId, &m_newMenuIds); KDesktopFile orig_df(path); KDesktopFile *df = orig_df.copyTo(result); df->desktopGroup().deleteEntry("Categories"); // Don't set any categories! KService::Ptr s(new KService(df)); s->setMenuId(menuId); MenuEntryInfo *entryInfo = new MenuEntryInfo(s, df); QString oldCaption = entryInfo->caption; QString newCaption = parentFolderInfo->uniqueItemCaption(oldCaption, oldCaption); entryInfo->setCaption(newCaption); // Add file to menu // m_menuFile->addEntry(folder, menuId); m_menuFile->pushAction(MenuFile::ADD_ENTRY, folder, menuId); // create the TreeItem if(parentItem) parentItem->setOpen(true); // update fileInfo data parentFolderInfo->add(entryInfo); TreeItem *newItem = createTreeItem(parentItem, after, entryInfo, true); setSelected ( newItem, true); itemSelected( newItem); m_drag = 0; setLayoutDirty(parentItem); return; } // is there content in the clipboard? if (!m_drag) return; if (m_dragItem == after) return; // Nothing to do int command = m_drag; if (command == MOVE_FOLDER) { MenuFolderInfo *folderInfo = m_dragInfo; if (e->action() == QDropEvent::Copy) { // Ugh.. this is hard :) // * Create new .directory file // Add } else { TreeItem *tmpItem = static_cast<TreeItem*>(parentItem); while ( tmpItem ) { if ( tmpItem == m_dragItem ) { m_drag = 0; return; } tmpItem = static_cast<TreeItem*>(tmpItem->parent() ); } // Remove MenuFolderInfo TreeItem *oldParentItem = static_cast<TreeItem*>(m_dragItem->parent()); MenuFolderInfo *oldParentFolderInfo = oldParentItem ? oldParentItem->folderInfo() : m_rootFolder; oldParentFolderInfo->take(folderInfo); // Move menu QString oldFolder = folderInfo->fullId; QString folderName = folderInfo->id; QString newFolder = m_menuFile->uniqueMenuName(folder, folderName, parentFolderInfo->existingMenuIds()); folderInfo->id = newFolder; // Add file to menu //m_menuFile->moveMenu(oldFolder, folder + newFolder); m_menuFile->pushAction(MenuFile::MOVE_MENU, oldFolder, folder + newFolder); // Make sure caption is unique QString newCaption = parentFolderInfo->uniqueMenuCaption(folderInfo->caption); if (newCaption != folderInfo->caption) { folderInfo->setCaption(newCaption); } // create the TreeItem if(parentItem) parentItem->setOpen(true); // update fileInfo data folderInfo->updateFullId(parentFolderInfo->fullId); folderInfo->setInUse(true); parentFolderInfo->add(folderInfo); if ((parentItem != oldParentItem) || !after) { if (oldParentItem) oldParentItem->takeItem(m_dragItem); else takeItem(m_dragItem); if (parentItem) parentItem->insertItem(m_dragItem); else insertItem(m_dragItem); } m_dragItem->moveItem(after); m_dragItem->setName(folderInfo->caption); m_dragItem->setDirectoryPath(folderInfo->fullId); setSelected(m_dragItem, true); itemSelected(m_dragItem); } } else if (command == MOVE_FILE) { MenuEntryInfo *entryInfo = m_dragItem->entryInfo(); QString menuId = entryInfo->menuId(); if (e->action() == QDropEvent::Copy) { // Need to copy file and then add it KDesktopFile *df = copyDesktopFile(entryInfo, &menuId, &m_newMenuIds); // Duplicate //UNDO-ACTION: NEW_MENU_ID (menuId) KService::Ptr s(new KService(df)); s->setMenuId(menuId); entryInfo = new MenuEntryInfo(s, df); QString oldCaption = entryInfo->caption; QString newCaption = parentFolderInfo->uniqueItemCaption(oldCaption, oldCaption); entryInfo->setCaption(newCaption); } else { del(m_dragItem, false); QString oldCaption = entryInfo->caption; QString newCaption = parentFolderInfo->uniqueItemCaption(oldCaption); entryInfo->setCaption(newCaption); entryInfo->setInUse(true); } // Add file to menu // m_menuFile->addEntry(folder, menuId); m_menuFile->pushAction(MenuFile::ADD_ENTRY, folder, menuId); // create the TreeItem if(parentItem) parentItem->setOpen(true); // update fileInfo data parentFolderInfo->add(entryInfo); TreeItem *newItem = createTreeItem(parentItem, after, entryInfo, true); setSelected ( newItem, true); itemSelected( newItem); } else if (command == COPY_SEPARATOR) { if (e->action() != QDropEvent::Copy) del(m_dragItem, false); TreeItem *newItem = createTreeItem(parentItem, after, m_separator, true); setSelected ( newItem, true); itemSelected( newItem); } else { // Error } m_drag = 0; setLayoutDirty(parentItem); }
sclklo() { sclk = 0; oport(); del(del_lo); }
template<class derived> void del(derived val) { base_type * p = get_ptr(val); del(p); }
sdihi() { sdi = 1; oport(); del(del_hi); }
extern "C" void* chk_realloc(void* ptr, size_t size) { // log_message("%s: %s\n", __FILE__, __FUNCTION__); if (!ptr) { return chk_malloc(size); } #ifdef REALLOC_ZERO_BYTES_FREE if (!size) { chk_free(ptr); return NULL; } #endif hdr_t* hdr = meta(ptr); if (del(hdr) < 0) { uintptr_t bt[MAX_BACKTRACE_DEPTH]; int depth = get_backtrace(bt, MAX_BACKTRACE_DEPTH); if (hdr->tag == BACKLOG_TAG) { log_message("+++ REALLOCATION %p SIZE %d OF FREED MEMORY!\n", user(hdr), size, hdr->size); log_message("+++ ALLOCATION %p SIZE %d ALLOCATED HERE:\n", user(hdr), hdr->size); log_backtrace(hdr->bt, hdr->bt_depth); /* hdr->freed_bt_depth should be nonzero here */ log_message("+++ ALLOCATION %p SIZE %d FIRST FREED HERE:\n", user(hdr), hdr->size); log_backtrace(hdr->freed_bt, hdr->freed_bt_depth); log_message("+++ ALLOCATION %p SIZE %d NOW BEING REALLOCATED HERE:\n", user(hdr), hdr->size); log_backtrace(bt, depth); /* We take the memory out of the backlog and fall through so the * reallocation below succeeds. Since we didn't really free it, we * can default to this behavior. */ del_from_backlog(hdr); } else { log_message("+++ REALLOCATION %p SIZE %d IS CORRUPTED OR NOT ALLOCATED VIA TRACKER!\n", user(hdr), size); log_backtrace(bt, depth); // just get a whole new allocation and leak the old one return Malloc(realloc)(0, size); // return realloc(user(hdr), size); // assuming it was allocated externally } } if (hdr->base != hdr) { // An allocation from memalign, so create another allocation and // copy the data out. void* newMem = Malloc(malloc)(sizeof(hdr_t) + size + sizeof(ftr_t)); if (newMem) { memcpy(newMem, hdr, sizeof(hdr_t) + hdr->size); Malloc(free)(hdr->base); hdr = static_cast<hdr_t*>(newMem); } else { Malloc(free)(hdr->base); hdr = NULL; } } else { hdr = static_cast<hdr_t*>(Malloc(realloc)(hdr, sizeof(hdr_t) + size + sizeof(ftr_t))); } if (hdr) { hdr->base = hdr; hdr->bt_depth = get_backtrace(hdr->bt, MAX_BACKTRACE_DEPTH); add(hdr, size); return user(hdr); } return NULL; }
sclkhi() { sclk = 1; oport(); del(del_hi); }
void ft_lstdelone(t_list **alst, void (*del)(void *, size_t)) { del((*alst)->content, (*alst)->content_size); ft_memdel((void**)alst); }
Ptr& operator=(const Ptr& in) { del(); data = in.data; if (data) ++data->refs; }
int TestDelegates::MarshalAnonymousDelegate(int (*del)(int n)) { return del(1); }