comparison src/gui_photon.c @ 16825:ce04ebdf26b8 v8.1.1414

patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts commit https://github.com/vim/vim/commit/c799fe206e61f2e2c1231bc46cbe4bb354f3da69 Author: Bram Moolenaar <Bram@vim.org> Date: Tue May 28 23:08:19 2019 +0200 patch 8.1.1414: alloc() returning "char_u *" causes a lot of type casts Problem: Alloc() returning "char_u *" causes a lot of type casts. Solution: Have it return "void *". (Mike Williams) Define ALLOC_ONE() to check the simple allocations.
author Bram Moolenaar <Bram@vim.org>
date Tue, 28 May 2019 23:15:10 +0200
parents cd5c83115ec6
children e1f4e9d78a6a
comparison
equal deleted inserted replaced
16824:1f6bb29738d2 16825:ce04ebdf26b8
974 static void 974 static void
975 gui_ph_pg_add_buffer(char *name) 975 gui_ph_pg_add_buffer(char *name)
976 { 976 {
977 char **new_titles = NULL; 977 char **new_titles = NULL;
978 978
979 new_titles = (char **) alloc((num_panels + 1) * sizeof(char **)); 979 new_titles = ALLOC_MULT(char *, (num_panels + 1));
980 if (new_titles != NULL) 980 if (new_titles != NULL)
981 { 981 {
982 if (num_panels > 0) 982 if (num_panels > 0)
983 memcpy(new_titles, panel_titles, num_panels * sizeof(char **)); 983 memcpy(new_titles, panel_titles, num_panels * sizeof(char **));
984 984
999 char **new_titles = NULL; 999 char **new_titles = NULL;
1000 1000
1001 /* If there is only 1 panel, we just use the temporary place holder */ 1001 /* If there is only 1 panel, we just use the temporary place holder */
1002 if (num_panels > 1) 1002 if (num_panels > 1)
1003 { 1003 {
1004 new_titles = (char **) alloc((num_panels - 1) * sizeof(char **)); 1004 new_titles = ALLOC_MULT(char *, num_panels - 1);
1005 if (new_titles != NULL) 1005 if (new_titles != NULL)
1006 { 1006 {
1007 char **s = new_titles; 1007 char **s = new_titles;
1008 /* Copy all the titles except the one we're removing */ 1008 /* Copy all the titles except the one we're removing */
1009 for (i = 0; i < num_panels; i++) 1009 for (i = 0; i < num_panels; i++)
1106 int flags = 0, n = 0; 1106 int flags = 0, n = 0;
1107 1107
1108 PhDim_t window_size = {100, 100}; /* Arbitrary values */ 1108 PhDim_t window_size = {100, 100}; /* Arbitrary values */
1109 PhPoint_t pos = {0, 0}; 1109 PhPoint_t pos = {0, 0};
1110 1110
1111 gui.event_buffer = (PhEvent_t *) alloc(EVENT_BUFFER_SIZE); 1111 gui.event_buffer = alloc(EVENT_BUFFER_SIZE);
1112 if (gui.event_buffer == NULL) 1112 if (gui.event_buffer == NULL)
1113 return FAIL; 1113 return FAIL;
1114 1114
1115 /* Get a translation so we can convert from ISO Latin-1 to UTF */ 1115 /* Get a translation so we can convert from ISO Latin-1 to UTF */
1116 charset_translate = PxTranslateSet(NULL, "latin1"); 1116 charset_translate = PxTranslateSet(NULL, "latin1");
1517 1517
1518 if (title == NULL) 1518 if (title == NULL)
1519 title = "Vim"; 1519 title = "Vim";
1520 1520
1521 buttons_copy = alloc(len + 1); 1521 buttons_copy = alloc(len + 1);
1522 button_array = (char_u **) alloc(button_count * sizeof(char_u *)); 1522 button_array = ALLOC_MULT(char_u *, button_count);
1523 if (buttons_copy != NULL && button_array != NULL) 1523 if (buttons_copy != NULL && button_array != NULL)
1524 { 1524 {
1525 STRCPY(buttons_copy, buttons); 1525 STRCPY(buttons_copy, buttons);
1526 1526
1527 /* 1527 /*