aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThiago de Arruda <tpadilha84@gmail.com>2015-04-13 09:30:57 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2015-04-13 09:30:57 -0300
commita9ee85b9fc2d4e3faa466e9c3062cd41315f8456 (patch)
treee45187575c9f0397c5d717780b61adf5b3976a62 /src
parent0248c75bc190ec2fbc8f3af3d61f771e76d628d6 (diff)
parent2d104f14dbd2c60a30e9e1e0fef098b39db087db (diff)
downloadrneovim-a9ee85b9fc2d4e3faa466e9c3062cd41315f8456.tar.gz
rneovim-a9ee85b9fc2d4e3faa466e9c3062cd41315f8456.tar.bz2
rneovim-a9ee85b9fc2d4e3faa466e9c3062cd41315f8456.zip
Merge PR #2415 'Use jemalloc instead of libc allocator'
Diffstat (limited to 'src')
-rw-r--r--src/nvim/CMakeLists.txt16
-rw-r--r--src/nvim/api/buffer.c12
-rw-r--r--src/nvim/api/private/helpers.c8
-rw-r--r--src/nvim/api/vim.c2
-rw-r--r--src/nvim/buffer.c76
-rw-r--r--src/nvim/diff.c40
-rw-r--r--src/nvim/digraph.c16
-rw-r--r--src/nvim/edit.c66
-rw-r--r--src/nvim/eval.c315
-rw-r--r--src/nvim/ex_cmds.c132
-rw-r--r--src/nvim/ex_cmds2.c76
-rw-r--r--src/nvim/ex_docmd.c128
-rw-r--r--src/nvim/ex_eval.c22
-rw-r--r--src/nvim/ex_getln.c104
-rw-r--r--src/nvim/file_search.c50
-rw-r--r--src/nvim/fileio.c134
-rw-r--r--src/nvim/fold.c4
-rw-r--r--src/nvim/garray.c4
-rw-r--r--src/nvim/garray.h2
-rw-r--r--src/nvim/getchar.c56
-rw-r--r--src/nvim/hardcopy.c12
-rw-r--r--src/nvim/hashtab.c6
-rw-r--r--src/nvim/if_cscope.c98
-rw-r--r--src/nvim/indent.c2
-rw-r--r--src/nvim/indent_c.c4
-rw-r--r--src/nvim/lib/khash.h2
-rw-r--r--src/nvim/lib/klist.h6
-rw-r--r--src/nvim/lib/kvec.h2
-rw-r--r--src/nvim/main.c10
-rw-r--r--src/nvim/map.c2
-rw-r--r--src/nvim/mark.c40
-rw-r--r--src/nvim/mbyte.c18
-rw-r--r--src/nvim/memfile.c42
-rw-r--r--src/nvim/memline.c68
-rw-r--r--src/nvim/memory.c32
-rw-r--r--src/nvim/menu.c58
-rw-r--r--src/nvim/message.c36
-rw-r--r--src/nvim/misc1.c20
-rw-r--r--src/nvim/misc2.c8
-rw-r--r--src/nvim/msgpack_rpc/channel.c25
-rw-r--r--src/nvim/msgpack_rpc/remote_ui.c4
-rw-r--r--src/nvim/msgpack_rpc/server.c6
-rw-r--r--src/nvim/normal.c18
-rw-r--r--src/nvim/ops.c74
-rw-r--r--src/nvim/option.c46
-rw-r--r--src/nvim/os/env.c22
-rw-r--r--src/nvim/os/event.c1
-rw-r--r--src/nvim/os/fs.c4
-rw-r--r--src/nvim/os/job_private.h9
-rw-r--r--src/nvim/os/pipe_process.c4
-rw-r--r--src/nvim/os/pty_process.c4
-rw-r--r--src/nvim/os/rstream.c10
-rw-r--r--src/nvim/os/shell.c10
-rw-r--r--src/nvim/os/signal.c16
-rw-r--r--src/nvim/os/wstream.c36
-rw-r--r--src/nvim/os_unix.c22
-rw-r--r--src/nvim/path.c52
-rw-r--r--src/nvim/popupmnu.c7
-rw-r--r--src/nvim/quickfix.c78
-rw-r--r--src/nvim/regexp.c30
-rw-r--r--src/nvim/regexp_nfa.c26
-rw-r--r--src/nvim/screen.c44
-rw-r--r--src/nvim/search.c50
-rw-r--r--src/nvim/spell.c164
-rw-r--r--src/nvim/strings.c2
-rw-r--r--src/nvim/syntax.c150
-rw-r--r--src/nvim/tag.c60
-rw-r--r--src/nvim/tempfile.c4
-rw-r--r--src/nvim/terminal.c12
-rw-r--r--src/nvim/tui/term_input.inl2
-rw-r--r--src/nvim/tui/tui.c10
-rw-r--r--src/nvim/undo.c40
-rw-r--r--src/nvim/window.c36
73 files changed, 1387 insertions, 1420 deletions
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 09b709b6ce..dc44c9135d 100644
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -1,11 +1,5 @@
include(CheckLibraryExists)
-option(SANITIZE "Enable Clang sanitizers for nvim binary" OFF)
-if(SANITIZE AND NOT CMAKE_C_COMPILER_ID MATCHES "Clang")
- message(WARNING "SANITIZE is only supported for Clang ... disabling")
- set(SANITIZE OFF)
-endif()
-
set(GENERATED_DIR ${PROJECT_BINARY_DIR}/src/nvim/auto)
set(DISPATCH_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/msgpack-gen.lua)
file(GLOB API_HEADERS api/*.h)
@@ -176,9 +170,16 @@ list(APPEND NVIM_LINK_LIBRARIES
${CMAKE_THREAD_LIBS_INIT}
)
+set(NVIM_EXEC_LINK_LIBRARIES ${NVIM_LINK_LIBRARIES})
+
+if(USE_JEMALLOC)
+ # dont use jemalloc in the unit test library
+ list(APPEND NVIM_EXEC_LINK_LIBRARIES ${JEMALLOC_LIBRARIES})
+endif()
+
add_executable(nvim ${NEOVIM_GENERATED_SOURCES} ${NEOVIM_SOURCES}
${NEOVIM_HEADERS})
-target_link_libraries(nvim ${NVIM_LINK_LIBRARIES})
+target_link_libraries(nvim ${NVIM_EXEC_LINK_LIBRARIES})
install_helper(TARGETS nvim)
if(SANITIZE)
@@ -199,5 +200,6 @@ set_property(TARGET libnvim APPEND_STRING PROPERTY COMPILE_FLAGS " -DMAKE_LIB ")
add_library(nvim-test MODULE EXCLUDE_FROM_ALL ${NEOVIM_GENERATED_SOURCES}
${NEOVIM_SOURCES} ${NEOVIM_HEADERS})
target_link_libraries(nvim-test ${NVIM_LINK_LIBRARIES})
+set_target_properties(nvim-test PROPERTIES COMPILE_FLAGS -DUNIT_TESTING)
add_subdirectory(po)
diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c
index 5bd48fc19f..c9ada8dfc0 100644
--- a/src/nvim/api/buffer.c
+++ b/src/nvim/api/buffer.c
@@ -58,7 +58,7 @@ String buffer_get_line(Buffer buffer, Integer index, Error *err)
rv = slice.items[0].data.string;
}
- free(slice.items);
+ xfree(slice.items);
return rv;
}
@@ -144,10 +144,10 @@ ArrayOf(String) buffer_get_line_slice(Buffer buffer,
end:
if (err->set) {
for (size_t i = 0; i < rv.size; i++) {
- free(rv.items[i].data.string.data);
+ xfree(rv.items[i].data.string.data);
}
- free(rv.items);
+ xfree(rv.items);
rv.items = NULL;
}
@@ -280,7 +280,7 @@ void buffer_set_line_slice(Buffer buffer,
}
// Same as with replacing, but we also need to free lines
- free(lines[i]);
+ xfree(lines[i]);
lines[i] = NULL;
extra++;
}
@@ -301,10 +301,10 @@ void buffer_set_line_slice(Buffer buffer,
end:
for (size_t i = 0; i < new_len; i++) {
- free(lines[i]);
+ xfree(lines[i]);
}
- free(lines);
+ xfree(lines);
restore_win_for_buf(save_curwin, save_curtab, save_curbuf);
try_end(err);
}
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 39ca0756f3..492da25a82 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -61,7 +61,7 @@ bool try_end(Error *err)
free_global_msglist();
if (should_free) {
- free(msg);
+ xfree(msg);
}
} else if (did_throw) {
api_set_error(err, Exception, "%s", current_exception->value);
@@ -489,7 +489,7 @@ void api_free_string(String value)
return;
}
- free(value.data);
+ xfree(value.data);
}
void api_free_object(Object value)
@@ -527,7 +527,7 @@ void api_free_array(Array value)
api_free_object(value.items[i]);
}
- free(value.items);
+ xfree(value.items);
}
void api_free_dictionary(Dictionary value)
@@ -537,7 +537,7 @@ void api_free_dictionary(Dictionary value)
api_free_object(value.items[i].value);
}
- free(value.items);
+ xfree(value.items);
}
Dictionary api_metadata(void)
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 587e19fe35..1204c9e1d1 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -85,7 +85,7 @@ void vim_feedkeys(String keys, String mode, Boolean escape_csi)
insert ? 0 : typebuf.tb_len, !typed, false);
if (escape_csi) {
- free(keys_esc);
+ xfree(keys_esc);
}
if (vgetc_busy)
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index 11cb7bdeac..4585278714 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -443,8 +443,8 @@ close_buffer (
* Remove the buffer from the list.
*/
if (wipe_buf) {
- free(buf->b_ffname);
- free(buf->b_sfname);
+ xfree(buf->b_ffname);
+ xfree(buf->b_sfname);
if (buf->b_prev == NULL)
firstbuf = buf->b_next;
else
@@ -563,7 +563,7 @@ static void free_buffer(buf_T *buf)
buf->b_next = au_pending_free_buf;
au_pending_free_buf = buf;
} else {
- free(buf);
+ xfree(buf);
}
}
@@ -587,7 +587,7 @@ free_buffer_stuff (
buf_delete_signs(buf); /* delete any signs */
map_clear_int(buf, MAP_ALL_MODES, TRUE, FALSE); /* clear local mappings */
map_clear_int(buf, MAP_ALL_MODES, TRUE, TRUE); /* clear local abbrevs */
- free(buf->b_start_fenc);
+ xfree(buf->b_start_fenc);
buf->b_start_fenc = NULL;
}
@@ -605,7 +605,7 @@ static void clear_wininfo(buf_T *buf)
clear_winopt(&wip->wi_opt);
deleteFoldRecurse(&wip->wi_folds);
}
- free(wip);
+ xfree(wip);
}
}
@@ -1332,7 +1332,7 @@ buflist_new (
if (ffname != NULL && !(flags & BLN_DUMMY)
&& (buf = buflist_findname_file_id(ffname, &file_id,
file_id_valid)) != NULL) {
- free(ffname);
+ xfree(ffname);
if (lnum != 0)
buflist_setfpos(buf, curwin, lnum, (colnr_T)0, FALSE);
/* copy the options now, if 'cpo' doesn't have 's' and not done
@@ -1396,9 +1396,9 @@ buflist_new (
buf->b_wininfo = xcalloc(1, sizeof(wininfo_T));
if (ffname != NULL && (buf->b_ffname == NULL || buf->b_sfname == NULL)) {
- free(buf->b_ffname);
+ xfree(buf->b_ffname);
buf->b_ffname = NULL;
- free(buf->b_sfname);
+ xfree(buf->b_sfname);
buf->b_sfname = NULL;
if (buf != curbuf)
free_buffer(buf);
@@ -1672,7 +1672,7 @@ buf_T *buflist_findname_exp(char_u *fname)
);
if (ffname != NULL) {
buf = buflist_findname(ffname);
- free(ffname);
+ xfree(ffname);
}
return buf;
}
@@ -1767,7 +1767,7 @@ buflist_findpat (
++p;
prog = vim_regcomp(p, p_magic ? RE_MAGIC : 0);
if (prog == NULL) {
- free(pat);
+ xfree(pat);
return -1;
}
@@ -1809,7 +1809,7 @@ buflist_findpat (
find_listed = FALSE;
}
- free(pat);
+ xfree(pat);
}
if (match == -2)
@@ -1855,7 +1855,7 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)
prog = vim_regcomp(patc + attempt * 11, RE_MAGIC);
if (prog == NULL) {
if (patc != pat)
- free(patc);
+ xfree(patc);
return FAIL;
}
@@ -1893,7 +1893,7 @@ int ExpandBufnames(char_u *pat, int *num_file, char_u ***file, int options)
}
if (patc != pat)
- free(patc);
+ xfree(patc);
*num_file = count;
return count == 0 ? FAIL : OK;
@@ -1938,7 +1938,7 @@ static char_u *fname_match(regprog_T *prog, char_u *name, bool ignore_case)
p = home_replace_save(NULL, name);
if (vim_regexec(&regmatch, p, (colnr_T)0))
match = name;
- free(p);
+ xfree(p);
}
}
@@ -2223,8 +2223,8 @@ setfname (
if (ffname == NULL || *ffname == NUL) {
/* Removing the name. */
- free(buf->b_ffname);
- free(buf->b_sfname);
+ xfree(buf->b_ffname);
+ xfree(buf->b_sfname);
buf->b_ffname = NULL;
buf->b_sfname = NULL;
} else {
@@ -2245,7 +2245,7 @@ setfname (
if (obuf->b_ml.ml_mfp != NULL) { /* it's loaded, fail */
if (message)
EMSG(_("E95: Buffer with this name already exists"));
- free(ffname);
+ xfree(ffname);
return FAIL;
}
/* delete from the list */
@@ -2255,8 +2255,8 @@ setfname (
#ifdef USE_FNAME_CASE
path_fix_case(sfname); /* set correct case for short file name */
#endif
- free(buf->b_ffname);
- free(buf->b_sfname);
+ xfree(buf->b_ffname);
+ xfree(buf->b_sfname);
buf->b_ffname = ffname;
buf->b_sfname = sfname;
}
@@ -2282,8 +2282,8 @@ void buf_set_name(int fnum, char_u *name)
buf = buflist_findnr(fnum);
if (buf != NULL) {
- free(buf->b_sfname);
- free(buf->b_ffname);
+ xfree(buf->b_sfname);
+ xfree(buf->b_ffname);
buf->b_ffname = vim_strsave(name);
buf->b_sfname = NULL;
/* Allocate ffname and expand into full path. Also resolves .lnk
@@ -2561,7 +2561,7 @@ fileinfo (
set_keep_msg(p, 0);
}
- free(buffer);
+ xfree(buffer);
}
void col_print(char_u *buf, size_t buflen, int col, int vcol)
@@ -2636,7 +2636,7 @@ void maketitle(void)
else {
p = transstr(path_tail(curbuf->b_fname));
STRLCPY(buf, p, SPACE_FOR_FNAME + 1);
- free(p);
+ xfree(p);
}
switch (bufIsChanged(curbuf)
@@ -2677,7 +2677,7 @@ void maketitle(void)
if (off < SPACE_FOR_DIR) {
p = transstr(buf + off);
STRLCPY(buf + off, p, SPACE_FOR_DIR - off + 1);
- free(p);
+ xfree(p);
} else {
STRLCPY(buf + off, "...", SPACE_FOR_ARGNR - off + 1);
}
@@ -2749,7 +2749,7 @@ static int ti_change(char_u *str, char_u **last)
{
if ((str == NULL) != (*last == NULL)
|| (str != NULL && *last != NULL && STRCMP(str, *last) != 0)) {
- free(*last);
+ xfree(*last);
if (str == NULL)
*last = NULL;
else
@@ -2771,8 +2771,8 @@ void resettitle(void)
# if defined(EXITFREE)
void free_titles(void)
{
- free(lasttitle);
- free(lasticon);
+ xfree(lasttitle);
+ xfree(lasticon);
}
# endif
@@ -3124,7 +3124,7 @@ build_stl_str_hl (
if (str != NULL && *str != 0) {
if (*skipdigits(str) == NUL) {
num = atoi((char *)str);
- free(str);
+ xfree(str);
str = NULL;
itemisflag = FALSE;
}
@@ -3381,7 +3381,7 @@ build_stl_str_hl (
item[curitem].type = Empty;
if (opt == STL_VIM_EXPR)
- free(str);
+ xfree(str);
if (num >= 0 || (!itemisflag && str && *str))
prevchar_isflag = FALSE; /* Item not NULL, but not a flag */
@@ -3391,7 +3391,7 @@ build_stl_str_hl (
itemcnt = curitem;
if (usefmt != fmt)
- free(usefmt);
+ xfree(usefmt);
width = vim_strsize(out);
if (maxwidth > 0 && width > maxwidth) {
@@ -3585,7 +3585,7 @@ void fname_expand(buf_T *buf, char_u **ffname, char_u **sfname)
/* If the file name is a shortcut file, use the file it links to. */
rfname = mch_resolve_shortcut(*ffname);
if (rfname != NULL) {
- free(*ffname);
+ xfree(*ffname);
*ffname = rfname;
*sfname = rfname;
}
@@ -3844,7 +3844,7 @@ do_arg_all (
win_enter(new_curwin, false);
--autocmd_no_leave;
- free(opened);
+ xfree(opened);
}
/*
@@ -4161,7 +4161,7 @@ chk_modeline (
sourcing_lnum = save_sourcing_lnum;
sourcing_name = save_sourcing_name;
- free(linecopy);
+ xfree(linecopy);
return retval;
}
@@ -4208,7 +4208,7 @@ int read_viminfo_bufferlist(vir_T *virp, int writing)
buflist_setfpos(buf, curwin, lnum, col, FALSE);
}
}
- free(xline);
+ xfree(xline);
return viminfo_readline(virp);
}
@@ -4249,7 +4249,7 @@ void write_viminfo_bufferlist(FILE *fp)
buf->b_last_cursor.col);
viminfo_writestring(fp, line);
}
- free(line);
+ xfree(line);
}
@@ -4426,7 +4426,7 @@ linenr_T buf_delsign(
if (sign->id == id) {
*lastp = next;
lnum = sign->lnum;
- free(sign);
+ xfree(sign);
break;
} else {
lastp = &sign->next;
@@ -4498,7 +4498,7 @@ void buf_delete_signs(buf_T *buf)
while (buf->b_signlist != NULL) {
next = buf->b_signlist->next;
- free(buf->b_signlist);
+ xfree(buf->b_signlist);
buf->b_signlist = next;
}
}
@@ -4621,7 +4621,7 @@ int buf_contents_changed(buf_T *buf)
}
}
}
- free(ea.cmd);
+ xfree(ea.cmd);
/* restore curwin/curbuf and a few other things */
aucmd_restbuf(&aco);
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index e50b096270..937baad648 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -393,7 +393,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1,
}
}
dprev->df_next = dp->df_next;
- free(dp);
+ xfree(dp);
dp = dprev->df_next;
} else {
// Advance to next entry.
@@ -416,7 +416,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1,
if (i == DB_COUNT) {
diff_T *dnext = dp->df_next;
- free(dp);
+ xfree(dp);
dp = dnext;
if (dprev == NULL) {
@@ -527,7 +527,7 @@ static void diff_check_unchanged(tabpage_T *tp, diff_T *dp)
break;
}
}
- free(line_org);
+ xfree(line_org);
// Stop when a line isn't equal in all diff buffers.
if (i_new != DB_COUNT) {
@@ -786,9 +786,9 @@ void ex_diffupdate(exarg_T *eap)
diff_redraw(TRUE);
theend:
- free(tmp_orig);
- free(tmp_new);
- free(tmp_diff);
+ xfree(tmp_orig);
+ xfree(tmp_new);
+ xfree(tmp_diff);
}
/// Make a diff between files "tmp_orig" and "tmp_new", results in "tmp_diff".
@@ -828,7 +828,7 @@ static void diff_file(char_u *tmp_orig, char_u *tmp_new, char_u *tmp_diff)
NULL
);
unblock_autocmds();
- free(cmd);
+ xfree(cmd);
}
}
@@ -989,16 +989,16 @@ theend:
if (tmp_orig != NULL) {
os_remove((char *)tmp_orig);
}
- free(tmp_orig);
+ xfree(tmp_orig);
if (tmp_new != NULL) {
os_remove((char *)tmp_new);
}
- free(tmp_new);
- free(newname);
- free(buf);
+ xfree(tmp_new);
+ xfree(newname);
+ xfree(buf);
#ifdef UNIX
- free(fullname);
+ xfree(fullname);
#endif // ifdef UNIX
}
@@ -1340,7 +1340,7 @@ static void diff_read(int idx_orig, int idx_new, char_u *fname)
while (dn != dp->df_next) {
dpl = dn->df_next;
- free(dn);
+ xfree(dn);
dn = dpl;
}
} else {
@@ -1407,7 +1407,7 @@ void diff_clear(tabpage_T *tp)
diff_T *next_p;
for (p = tp->tp_first_diff; p != NULL; p = next_p) {
next_p = p->df_next;
- free(p);
+ xfree(p);
}
tp->tp_first_diff = NULL;
}
@@ -1559,7 +1559,7 @@ static int diff_equal_entry(diff_T *dp, int idx1, int idx2)
int cmp = diff_cmp(line, ml_get_buf(curtab->tp_diffbuf[idx2],
dp->df_lnum[idx2] + i, FALSE));
- free(line);
+ xfree(line);
if (cmp != 0) {
return FALSE;
@@ -1863,7 +1863,7 @@ int diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
int idx = diff_buf_idx(wp->w_buffer);
if (idx == DB_COUNT) {
// cannot happen
- free(line_org);
+ xfree(line_org);
return FALSE;
}
@@ -1876,7 +1876,7 @@ int diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
}
if ((dp == NULL) || (diff_check_sanity(curtab, dp) == FAIL)) {
- free(line_org);
+ xfree(line_org);