diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-12-01 18:13:55 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-12-04 08:56:11 +0900 |
| commit | ff8b608c52a4364fdf5896d4c600018d907dfc95 (patch) | |
| tree | 17c8034c11c3c5398a0247e5262b4332d309e173 /mrbgems/mruby-bin-mirb | |
| parent | cd9f53d42eae3b57ebc5c75492dcf372a627f300 (diff) | |
| download | mruby-ff8b608c52a4364fdf5896d4c600018d907dfc95.tar.gz mruby-ff8b608c52a4364fdf5896d4c600018d907dfc95.zip | |
Free read lines using the deallocation function from the library.
To avoid potential `malloc/free` mismatch.
Diffstat (limited to 'mrbgems/mruby-bin-mirb')
| -rw-r--r-- | mrbgems/mruby-bin-mirb/tools/mirb/mirb.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c b/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c index 8084e8af3..4d01c1696 100644 --- a/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +++ b/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c @@ -19,6 +19,7 @@ #include <readline/history.h> #define MIRB_ADD_HISTORY(line) add_history(line) #define MIRB_READLINE(ch) readline(ch) +#define MIRB_LINE_FREE(line) rl_free(line) #define MIRB_WRITE_HISTORY(path) write_history(path) #define MIRB_READ_HISTORY(path) read_history(path) #define MIRB_USING_HISTORY() using_history() @@ -27,6 +28,7 @@ #include <linenoise.h> #define MIRB_ADD_HISTORY(line) linenoiseHistoryAdd(line) #define MIRB_READLINE(ch) linenoise(ch) +#define MIRB_LINE_FREE(line) linenoiseFree(line) #define MIRB_WRITE_HISTORY(path) linenoiseHistorySave(path) #define MIRB_READ_HISTORY(path) linenoiseHistoryLoad(history_path) #define MIRB_USING_HISTORY() @@ -489,7 +491,7 @@ main(int argc, char **argv) strcpy(last_code_line, line); strcat(last_code_line, "\n"); MIRB_ADD_HISTORY(line); - free(line); + MIRB_LINE_FREE(line); #endif done: |
