comparison src/quickfix.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 fc58fee685e2
children 15bc5a64bd50
comparison
equal deleted inserted replaced
16824:1f6bb29738d2 16825:ce04ebdf26b8
538 goto parse_efm_error; 538 goto parse_efm_error;
539 539
540 while (efm[0] != NUL) 540 while (efm[0] != NUL)
541 { 541 {
542 // Allocate a new eformat structure and put it at the end of the list 542 // Allocate a new eformat structure and put it at the end of the list
543 fmt_ptr = (efm_T *)alloc_clear(sizeof(efm_T)); 543 fmt_ptr = ALLOC_CLEAR_ONE(efm_T);
544 if (fmt_ptr == NULL) 544 if (fmt_ptr == NULL)
545 goto parse_efm_error; 545 goto parse_efm_error;
546 if (fmt_first == NULL) // first one 546 if (fmt_first == NULL) // first one
547 fmt_first = fmt_ptr; 547 fmt_first = fmt_ptr;
548 else 548 else
1888 static void 1888 static void
1889 locstack_queue_delreq(qf_info_T *qi) 1889 locstack_queue_delreq(qf_info_T *qi)
1890 { 1890 {
1891 qf_delq_T *q; 1891 qf_delq_T *q;
1892 1892
1893 q = (qf_delq_T *)alloc(sizeof(qf_delq_T)); 1893 q = ALLOC_ONE(qf_delq_T);
1894 if (q != NULL) 1894 if (q != NULL)
1895 { 1895 {
1896 q->qi = qi; 1896 q->qi = qi;
1897 q->next = qf_delq_head; 1897 q->next = qf_delq_head;
1898 qf_delq_head = q; 1898 qf_delq_head = q;
2061 int valid) // valid entry 2061 int valid) // valid entry
2062 { 2062 {
2063 qfline_T *qfp; 2063 qfline_T *qfp;
2064 qfline_T **lastp; // pointer to qf_last or NULL 2064 qfline_T **lastp; // pointer to qf_last or NULL
2065 2065
2066 if ((qfp = (qfline_T *)alloc(sizeof(qfline_T))) == NULL) 2066 if ((qfp = ALLOC_ONE(qfline_T)) == NULL)
2067 return QF_FAIL; 2067 return QF_FAIL;
2068 if (bufnum != 0) 2068 if (bufnum != 0)
2069 { 2069 {
2070 buf_T *buf = buflist_findnr(bufnum); 2070 buf_T *buf = buflist_findnr(bufnum);
2071 2071
2139 static qf_info_T * 2139 static qf_info_T *
2140 qf_alloc_stack(qfltype_T qfltype) 2140 qf_alloc_stack(qfltype_T qfltype)
2141 { 2141 {
2142 qf_info_T *qi; 2142 qf_info_T *qi;
2143 2143
2144 qi = (qf_info_T *)alloc_clear(sizeof(qf_info_T)); 2144 qi = ALLOC_CLEAR_ONE(qf_info_T);
2145 if (qi != NULL) 2145 if (qi != NULL)
2146 { 2146 {
2147 qi->qf_refcount++; 2147 qi->qf_refcount++;
2148 qi->qfl_type = qfltype; 2148 qi->qfl_type = qfltype;
2149 qi->qf_bufnr = INVALID_QFBUFNR; 2149 qi->qf_bufnr = INVALID_QFBUFNR;
2427 { 2427 {
2428 struct dir_stack_T *ds_new; 2428 struct dir_stack_T *ds_new;
2429 struct dir_stack_T *ds_ptr; 2429 struct dir_stack_T *ds_ptr;
2430 2430
2431 // allocate new stack element and hook it in 2431 // allocate new stack element and hook it in
2432 ds_new = (struct dir_stack_T *)alloc(sizeof(struct dir_stack_T)); 2432 ds_new = ALLOC_ONE(struct dir_stack_T);
2433 if (ds_new == NULL) 2433 if (ds_new == NULL)
2434 return NULL; 2434 return NULL;
2435 2435
2436 ds_new->next = *stackptr; 2436 ds_new->next = *stackptr;
2437 *stackptr = ds_new; 2437 *stackptr = ds_new;