X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=visor;a=blobdiff_plain;f=libvisor%2Fsrc%2Fvisor.c;h=84ffd95d45fdccd909a08cb26dddefb5940d3ad2;hp=86d508b202909556500b6738b0e539b67f78599f;hb=c17213b9500cfb26ba0d85b1a63c9aeb56981748;hpb=1c7c43c39b2b6f9224bcd39e3a24b8e91ada2cae diff --git a/libvisor/src/visor.c b/libvisor/src/visor.c index 86d508b..84ffd95 100644 --- a/libvisor/src/visor.c +++ b/libvisor/src/visor.c @@ -100,13 +100,15 @@ void vi_term_size(struct visor *vi, int xsz, int ysz) void vi_redraw(struct visor *vi) { - int i, col, cur_x = 0, cur_y = 0; + int i = 0, col, cur_x = 0, cur_y = 0; char c; struct vi_buffer *vb; struct vi_span *sp, *spans_end; const char *tptr, *tend; vi_addr spoffs, addr; + if(!vi->buflist) goto end; + vb = vi->buflist; if(!(sp = vi_buf_find_span(vb, vb->view_start, &spoffs))) { sp = vb->spans; @@ -215,8 +217,16 @@ int vi_delete_buf(struct visor *vi, struct vi_buffer *vb) return -1; } + if(vb->fp) { + if(vb->file_mapped) { + vi_unmap(vb->fp); + } else { + vi_free(vb->orig); + } + vi_close(vb->fp); + } + vi_free(vb->path); - vi_free(vb->orig); vi_free(vb->add); vi_free(vb->spans); return 0;