diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-05-22 12:50:59 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-05-22 13:00:51 -0400 |
commit | e2e47803bdfd5fb40e3dbc9cdf798bb27d306c72 (patch) | |
tree | 6ff1b06b5d5fd6d3260f3a778c33cfaf03f0c295 /src/nvim/digraph.c | |
parent | 0aa8b5828cc0674894681841f40c3c05bfd2f07b (diff) | |
parent | e303a11ebfc352860cce73184ece692ab4d0f01c (diff) | |
download | rneovim-e2e47803bdfd5fb40e3dbc9cdf798bb27d306c72.tar.gz rneovim-e2e47803bdfd5fb40e3dbc9cdf798bb27d306c72.tar.bz2 rneovim-e2e47803bdfd5fb40e3dbc9cdf798bb27d306c72.zip |
Merge #708 'Remove NULL/non-NULL tests after vim_str(n)save'
- replace alloc with xmalloc
Diffstat (limited to 'src/nvim/digraph.c')
-rw-r--r-- | src/nvim/digraph.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index b7f0c40788..443640d23d 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1738,28 +1738,24 @@ char_u* keymap_init(void) keymap_unload(); do_cmdline_cmd((char_u *)"unlet! b:keymap_name"); } else { - char_u *buf; + char *buf; size_t buflen; // Source the keymap file. It will contain a ":loadkeymap" command // which will call ex_loadkeymap() below. buflen = STRLEN(curbuf->b_p_keymap) + STRLEN(p_enc) + 14; - buf = alloc((unsigned)buflen); - - if (buf == NULL) { - return e_outofmem; - } + buf = xmalloc(buflen); // try finding "keymap/'keymap'_'encoding'.vim" in 'runtimepath' - vim_snprintf((char *)buf, buflen, "keymap/%s_%s.vim", + vim_snprintf(buf, buflen, "keymap/%s_%s.vim", curbuf->b_p_keymap, p_enc); - if (source_runtime(buf, FALSE) == FAIL) { + if (source_runtime((char_u *)buf, FALSE) == FAIL) { // try finding "keymap/'keymap'.vim" in 'runtimepath' - vim_snprintf((char *)buf, buflen, "keymap/%s.vim", + vim_snprintf(buf, buflen, "keymap/%s.vim", curbuf->b_p_keymap); - if (source_runtime(buf, FALSE) == FAIL) { + if (source_runtime((char_u *)buf, FALSE) == FAIL) { free(buf); return (char_u *)N_("E544: Keymap file not found"); } @@ -1818,12 +1814,10 @@ void ex_loadkeymap(exarg_T *eap) s = skiptowhite(p); kp->to = vim_strnsave(p, (int)(s - p)); - if ((kp->from == NULL) - || (kp->to == NULL) - || (STRLEN(kp->from) + STRLEN(kp->to) >= KMAP_LLEN) + if ((STRLEN(kp->from) + STRLEN(kp->to) >= KMAP_LLEN) || (*kp->from == NUL) || (*kp->to == NUL)) { - if ((kp->to != NULL) && (*kp->to == NUL)) { + if (*kp->to == NUL) { EMSG(_("E791: Empty keymap entry")); } free(kp->from); |