Mercurial > vim
comparison src/terminal.c @ 16782:fc58fee685e2 v8.1.1393
patch 8.1.1393: unnecessary type casts
commit https://github.com/vim/vim/commit/51e14387f120392b74b84408cafec33942337a05
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat May 25 20:21:28 2019 +0200
patch 8.1.1393: unnecessary type casts
Problem: Unnecessary type casts.
Solution: Remove type casts from alloc() and lalloc() calls. (Mike Williams)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 25 May 2019 20:30:06 +0200 |
parents | eda4d65f232c |
children | ce04ebdf26b8 |
comparison
equal
deleted
inserted
replaced
16781:db5dc8db015c | 16782:fc58fee685e2 |
---|---|
532 || (cmd = tv_get_string_chk( | 532 || (cmd = tv_get_string_chk( |
533 &argvar->vval.v_list->lv_first->li_tv)) == NULL) | 533 &argvar->vval.v_list->lv_first->li_tv)) == NULL) |
534 cmd = (char_u*)""; | 534 cmd = (char_u*)""; |
535 | 535 |
536 len = STRLEN(cmd) + 10; | 536 len = STRLEN(cmd) + 10; |
537 p = alloc((int)len); | 537 p = alloc(len); |
538 | 538 |
539 for (i = 0; p != NULL; ++i) | 539 for (i = 0; p != NULL; ++i) |
540 { | 540 { |
541 /* Prepend a ! to the command name to avoid the buffer name equals | 541 /* Prepend a ! to the command name to avoid the buffer name equals |
542 * the executable, otherwise ":w!" would overwrite it. */ | 542 * the executable, otherwise ":w!" would overwrite it. */ |
1628 } | 1628 } |
1629 | 1629 |
1630 if (len == 0) | 1630 if (len == 0) |
1631 p = NULL; | 1631 p = NULL; |
1632 else | 1632 else |
1633 p = (cellattr_T *)alloc((int)sizeof(cellattr_T) * len); | 1633 p = (cellattr_T *)alloc(sizeof(cellattr_T) * len); |
1634 if ((p != NULL || len == 0) | 1634 if ((p != NULL || len == 0) |
1635 && ga_grow(&term->tl_scrollback, 1) == OK) | 1635 && ga_grow(&term->tl_scrollback, 1) == OK) |
1636 { | 1636 { |
1637 garray_T ga; | 1637 garray_T ga; |
1638 int width; | 1638 int width; |
2882 else | 2882 else |
2883 cell2cellattr(&cells[i], &fill_attr); | 2883 cell2cellattr(&cells[i], &fill_attr); |
2884 | 2884 |
2885 ga_init2(&ga, 1, 100); | 2885 ga_init2(&ga, 1, 100); |
2886 if (len > 0) | 2886 if (len > 0) |
2887 p = (cellattr_T *)alloc((int)sizeof(cellattr_T) * len); | 2887 p = (cellattr_T *)alloc(sizeof(cellattr_T) * len); |
2888 if (p != NULL) | 2888 if (p != NULL) |
2889 { | 2889 { |
2890 for (col = 0; col < len; col += cells[col].width) | 2890 for (col = 0; col < len; col += cells[col].width) |
2891 { | 2891 { |
2892 if (ga_grow(&ga, MB_MAXBYTES) == FAIL) | 2892 if (ga_grow(&ga, MB_MAXBYTES) == FAIL) |
3716 p = dict_get_string(dict, (char_u *)"enc", FALSE); | 3716 p = dict_get_string(dict, (char_u *)"enc", FALSE); |
3717 if (p == NULL) | 3717 if (p == NULL) |
3718 p = dict_get_string(dict, (char_u *)"encoding", FALSE); | 3718 p = dict_get_string(dict, (char_u *)"encoding", FALSE); |
3719 if (p != NULL) | 3719 if (p != NULL) |
3720 { | 3720 { |
3721 ea.cmd = alloc((int)STRLEN(p) + 12); | 3721 ea.cmd = alloc(STRLEN(p) + 12); |
3722 if (ea.cmd != NULL) | 3722 if (ea.cmd != NULL) |
3723 { | 3723 { |
3724 sprintf((char *)ea.cmd, "sbuf ++enc=%s", p); | 3724 sprintf((char *)ea.cmd, "sbuf ++enc=%s", p); |
3725 ea.force_enc = 11; | 3725 ea.force_enc = 11; |
3726 tofree = ea.cmd; | 3726 tofree = ea.cmd; |
4029 else if (term_job_running(term)) | 4029 else if (term_job_running(term)) |
4030 txt = (char_u *)_("running"); | 4030 txt = (char_u *)_("running"); |
4031 else | 4031 else |
4032 txt = (char_u *)_("finished"); | 4032 txt = (char_u *)_("finished"); |
4033 len = 9 + STRLEN(term->tl_buffer->b_fname) + STRLEN(txt); | 4033 len = 9 + STRLEN(term->tl_buffer->b_fname) + STRLEN(txt); |
4034 term->tl_status_text = alloc((int)len); | 4034 term->tl_status_text = alloc(len); |
4035 if (term->tl_status_text != NULL) | 4035 if (term->tl_status_text != NULL) |
4036 vim_snprintf((char *)term->tl_status_text, len, "%s [%s]", | 4036 vim_snprintf((char *)term->tl_status_text, len, "%s [%s]", |
4037 term->tl_buffer->b_fname, txt); | 4037 term->tl_buffer->b_fname, txt); |
4038 } | 4038 } |
4039 return term->tl_status_text; | 4039 return term->tl_status_text; |
4661 | 4661 |
4662 if (opt.jo_term_name == NULL) | 4662 if (opt.jo_term_name == NULL) |
4663 { | 4663 { |
4664 size_t len = STRLEN(fname1) + 12; | 4664 size_t len = STRLEN(fname1) + 12; |
4665 | 4665 |
4666 fname_tofree = alloc((int)len); | 4666 fname_tofree = alloc(len); |
4667 if (fname_tofree != NULL) | 4667 if (fname_tofree != NULL) |
4668 { | 4668 { |
4669 vim_snprintf((char *)fname_tofree, len, "dump diff %s", fname1); | 4669 vim_snprintf((char *)fname_tofree, len, "dump diff %s", fname1); |
4670 opt.jo_term_name = fname_tofree; | 4670 opt.jo_term_name = fname_tofree; |
4671 } | 4671 } |
4933 } | 4933 } |
4934 } | 4934 } |
4935 else | 4935 else |
4936 { | 4936 { |
4937 size_t size = sizeof(sb_line_T) * term->tl_scrollback.ga_len; | 4937 size_t size = sizeof(sb_line_T) * term->tl_scrollback.ga_len; |
4938 sb_line_T *temp = (sb_line_T *)alloc((int)size); | 4938 sb_line_T *temp = (sb_line_T *)alloc(size); |
4939 | 4939 |
4940 /* need to copy cell properties into temp memory */ | 4940 /* need to copy cell properties into temp memory */ |
4941 if (temp != NULL) | 4941 if (temp != NULL) |
4942 { | 4942 { |
4943 mch_memmove(temp, term->tl_scrollback.ga_data, size); | 4943 mch_memmove(temp, term->tl_scrollback.ga_data, size); |
5798 | 5798 |
5799 if (cmd_wchar != NULL) | 5799 if (cmd_wchar != NULL) |
5800 { | 5800 { |
5801 /* Request by CreateProcessW */ | 5801 /* Request by CreateProcessW */ |
5802 breq = wcslen(cmd_wchar) + 1 + 1; /* Addition of NUL by API */ | 5802 breq = wcslen(cmd_wchar) + 1 + 1; /* Addition of NUL by API */ |
5803 cmd_wchar_copy = (PWSTR)alloc((int)(breq * sizeof(WCHAR))); | 5803 cmd_wchar_copy = (PWSTR)alloc(breq * sizeof(WCHAR)); |
5804 wcsncpy(cmd_wchar_copy, cmd_wchar, breq - 1); | 5804 wcsncpy(cmd_wchar_copy, cmd_wchar, breq - 1); |
5805 } | 5805 } |
5806 | 5806 |
5807 ga_clear(&ga_cmd); | 5807 ga_clear(&ga_cmd); |
5808 if (cmd_wchar == NULL) | 5808 if (cmd_wchar == NULL) |
5828 term->tl_siex.StartupInfo.cb = sizeof(term->tl_siex); | 5828 term->tl_siex.StartupInfo.cb = sizeof(term->tl_siex); |
5829 | 5829 |
5830 /* Set up pipe inheritance safely: Vista or later. */ | 5830 /* Set up pipe inheritance safely: Vista or later. */ |
5831 pInitializeProcThreadAttributeList(NULL, 1, 0, &breq); | 5831 pInitializeProcThreadAttributeList(NULL, 1, 0, &breq); |
5832 term->tl_siex.lpAttributeList = | 5832 term->tl_siex.lpAttributeList = |
5833 (PPROC_THREAD_ATTRIBUTE_LIST)alloc((int)breq); | 5833 (PPROC_THREAD_ATTRIBUTE_LIST)alloc(breq); |
5834 if (!term->tl_siex.lpAttributeList) | 5834 if (!term->tl_siex.lpAttributeList) |
5835 goto failed; | 5835 goto failed; |
5836 if (!pInitializeProcThreadAttributeList(term->tl_siex.lpAttributeList, 1, | 5836 if (!pInitializeProcThreadAttributeList(term->tl_siex.lpAttributeList, 1, |
5837 0, &breq)) | 5837 0, &breq)) |
5838 goto failed; | 5838 goto failed; |