void Bterm(Buffer *b) { Dclose(b->disc); Strclose(&b->cache); free(b); }
void shutdown(void) { freecmd(); for (int i = 0; i < file.nused; i++) Fclose(file.filepptr[i]); if (!downloaded) Fclose(cmd); if (genc) free(genc); Strclose(&cmdstr); Strclose(&lastpat); Strclose(&lastregexp); Strclose(&genstr); Strclose(&rhs); Strclose(&wd); Strclose(&plan9cmd); if (file.listptr) free(file.listptr); if (tempfile.listptr) free(tempfile.listptr); freecmdlists(); freebufs(); }
void fileclose(File *f) { Strclose(&f->name); bufclose(&f->Buffer); bufclose(&f->delta); bufclose(&f->epsilon); if(f->rasp) listfree(f->rasp); free(f); }
void freecmd(void) { int i; while(cmdlist.nused > 0) free(cmdlist.voidpptr[--cmdlist.nused]); while(addrlist.nused > 0) free(addrlist.voidpptr[--addrlist.nused]); while(relist.nused > 0){ i = --relist.nused; Strclose(relist.stringpptr[i]); free(relist.stringpptr[i]); } while(stringlist.nused>0){ i = --stringlist.nused; Strclose(stringlist.stringpptr[i]); free(stringlist.stringpptr[i]); } }
void fileunsetname(File *f, Buffer *delta) { String s; Undo u; /* undo a file name change by restoring old name */ u.type = Filename; u.mod = f->mod; u.seq = f->seq; u.p0 = 0; /* unused */ Strinit(&s); Strduplstr(&s, &f->name); fullname(&s); u.n = s.n; if(s.n) bufinsert(delta, delta->nc, s.s, s.n); bufinsert(delta, delta->nc, (Rune*)&u, Undosize); Strclose(&s); }