comparison src/os_mswin.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 695d9ef00b03
children f42aa3d90b12
comparison
equal deleted inserted replaced
16824:1f6bb29738d2 16825:ce04ebdf26b8
1799 1799
1800 if (h == INVALID_HANDLE_VALUE) 1800 if (h == INVALID_HANDLE_VALUE)
1801 goto fail; 1801 goto fail;
1802 1802
1803 size = sizeof(FILE_NAME_INFO_) + sizeof(WCHAR) * (MAX_PATH - 1); 1803 size = sizeof(FILE_NAME_INFO_) + sizeof(WCHAR) * (MAX_PATH - 1);
1804 nameinfo = (FILE_NAME_INFO_*)alloc(size + sizeof(WCHAR)); 1804 nameinfo = alloc(size + sizeof(WCHAR));
1805 if (nameinfo == NULL) 1805 if (nameinfo == NULL)
1806 goto fail; 1806 goto fail;
1807 1807
1808 if (!pGetFileInformationByHandleEx(h, FileNameInfo_, nameinfo, size)) 1808 if (!pGetFileInformationByHandleEx(h, FileNameInfo_, nameinfo, size))
1809 goto fail; 1809 goto fail;
1833 size = 0; 1833 size = 0;
1834 if (!GetVolumePathNamesForVolumeNameW(buff, NULL, 0, &size) && 1834 if (!GetVolumePathNamesForVolumeNameW(buff, NULL, 0, &size) &&
1835 GetLastError() != ERROR_MORE_DATA) 1835 GetLastError() != ERROR_MORE_DATA)
1836 goto fail; 1836 goto fail;
1837 1837
1838 volnames = (WCHAR*)alloc(size * sizeof(WCHAR)); 1838 volnames = ALLOC_MULT(WCHAR, size);
1839 if (!GetVolumePathNamesForVolumeNameW(buff, volnames, size, 1839 if (!GetVolumePathNamesForVolumeNameW(buff, volnames, size,
1840 &size)) 1840 &size))
1841 goto fail; 1841 goto fail;
1842 1842
1843 wcscpy(buff, volnames); 1843 wcscpy(buff, volnames);
3076 theend: 3076 theend:
3077 /* ron: init lastlf */ 3077 /* ron: init lastlf */
3078 if (ret == OK && printer_dc == NULL) 3078 if (ret == OK && printer_dc == NULL)
3079 { 3079 {
3080 vim_free(lastlf); 3080 vim_free(lastlf);
3081 lastlf = (LOGFONTW *)alloc(sizeof(LOGFONTW)); 3081 lastlf = ALLOC_ONE(LOGFONTW);
3082 if (lastlf != NULL) 3082 if (lastlf != NULL)
3083 mch_memmove(lastlf, lf, sizeof(LOGFONTW)); 3083 mch_memmove(lastlf, lf, sizeof(LOGFONTW));
3084 } 3084 }
3085 vim_free(wname); 3085 vim_free(wname);
3086 3086