Skip to content

Commit

Permalink
next: Step 123
Browse files Browse the repository at this point in the history
  • Loading branch information
Gurrium committed Jan 26, 2023
1 parent ca6c441 commit 4ea2943
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions kilo.c
Expand Up @@ -231,10 +231,12 @@ void editorUpdateRow(erow *row) {
row->rsize = idx;
}

void editorAppendRow(char *s, size_t len) {
void editorInsertRow(int at, char *s, size_t len) {
if (at < 0 || at > E.numrows) return;

E.row = realloc(E.row, sizeof(erow) * (E.numrows + 1));
memmove(&E.row[at + 1], &E.row[at], sizeof(erow) * (E.numrows - at));

int at = E.numrows;
E.row[at].size = len;
E.row[at].chars = malloc(len + 1);
memcpy(E.row[at].chars, s, len);
Expand Down

0 comments on commit 4ea2943

Please sign in to comment.