Skip to content

Commit

Permalink
Fix for an history bug
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Mar 21, 2010
1 parent 773b5d2 commit e5dee80
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.markdown
@@ -1,6 +1,6 @@
# Linenoise

A minimal, zero-config, readline replacement.
A minimal, zero-config, BSD licensed, readline replacement.

## Can a line editing library be 20k lines of code?

Expand Down
4 changes: 2 additions & 2 deletions linenoise.c
Expand Up @@ -308,7 +308,7 @@ int linenoiseHistoryAdd(char *line) {
line = strdup(line);
if (!line) return 0;
if (history_len == history_max_len) {
memmove(history,history+sizeof(char*),sizeof(char*)*history_max_len-1);
memmove(history,history+1,sizeof(char*)*(history_max_len-1));
history_len--;
}
history[history_len] = line;
Expand All @@ -326,7 +326,7 @@ int linenoiseHistorySetMaxLen(int len) {
new = malloc(sizeof(char*)*len);
if (new == NULL) return 0;
if (len < tocopy) tocopy = len;
memcpy(new,history-sizeof(char*)*tocopy, sizeof(char*)*tocopy);
memcpy(new,history+(history_max_len-tocopy), sizeof(char*)*tocopy);
free(history);
history = new;
}
Expand Down

0 comments on commit e5dee80

Please sign in to comment.