Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffers #19

Open
wants to merge 5 commits into
base: buffers
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions ex.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ static struct buf {
long mtime; /* modification time */
} bufs[8];

static int bufs_cnt = 0; /* number of allocated buffers */

static int bufs_find(char *path)
{
int i;
Expand All @@ -52,7 +50,6 @@ static void bufs_free(int idx)
if (bufs[idx].lb) {
free(bufs[idx].path);
lbuf_free(bufs[idx].lb);
memset(&bufs[idx], 0, sizeof(bufs[idx]));
}
}

Expand All @@ -70,8 +67,9 @@ static int bufs_open(char *path)
for (i = 0; i < LEN(bufs) - 1; i++)
if (!bufs[i].lb)
break;
if (!bufs[i].lb)
bufs[i].id = i + 1;
bufs_free(i);
bufs[i].id = ++bufs_cnt;
bufs[i].path = uc_dup(path);
bufs[i].lb = lbuf_make();
bufs[i].row = 0;
Expand Down