https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d0a52a6d714cf195eb828…
commit d0a52a6d714cf195eb828821fa537f135565d041
Author: Timo Kreuzer <timo.kreuzer(a)reactos.org>
AuthorDate: Tue Jan 10 11:20:11 2023 +0200
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Tue Jan 24 18:53:13 2023 +0100
[CRT] Reduce diff
- use msvcrt_set_errno
- MSVCRT_CHECK_PMT already sets the error.
- NULL check is already in HeapFree
---
sdk/lib/crt/wine/heap.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/sdk/lib/crt/wine/heap.c b/sdk/lib/crt/wine/heap.c
index 2c3f5ffe260..39e2e0c44b9 100644
--- a/sdk/lib/crt/wine/heap.c
+++ b/sdk/lib/crt/wine/heap.c
@@ -44,6 +44,7 @@
#define MSVCRT_free free
#define MSVCRT_memmove_s memmove_s
#define MSVCRT_strncpy_s strncpy_s
+#define msvcrt_set_errno _dosmaperr
/* MT */
#define LOCK_HEAP _mlock( _HEAP_LOCK )
@@ -277,7 +278,7 @@ int CDECL _heapchk(void)
if (!HeapValidate(heap, 0, NULL) ||
(sb_heap && !HeapValidate(sb_heap, 0, NULL)))
{
- _dosmaperr(GetLastError());
+ msvcrt_set_errno(GetLastError());
return MSVCRT__HEAPBADNODE;
}
return MSVCRT__HEAPOK;
@@ -292,7 +293,7 @@ int CDECL _heapmin(void)
(sb_heap && !HeapCompact( sb_heap, 0 )))
{
if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
- _dosmaperr(GetLastError());
+ msvcrt_set_errno(GetLastError());
return -1;
}
return 0;
@@ -317,7 +318,7 @@ int CDECL _heapwalk(struct MSVCRT__heapinfo* next)
!HeapValidate( heap, 0, phe.lpData ))
{
UNLOCK_HEAP;
- _dosmaperr(GetLastError());
+ msvcrt_set_errno(GetLastError());
return MSVCRT__HEAPBADNODE;
}
@@ -328,7 +329,7 @@ int CDECL _heapwalk(struct MSVCRT__heapinfo* next)
UNLOCK_HEAP;
if (GetLastError() == ERROR_NO_MORE_ITEMS)
return MSVCRT__HEAPEND;
- _dosmaperr(GetLastError());
+ msvcrt_set_errno(GetLastError());
if (!phe.lpData)
return MSVCRT__HEAPBADBEGIN;
return MSVCRT__HEAPBADNODE;
@@ -406,7 +407,6 @@ void* CDECL MSVCRT_calloc(MSVCRT_size_t count, MSVCRT_size_t size)
*/
void CDECL MSVCRT_free(void* ptr)
{
- if(ptr == NULL) return;
msvcrt_heap_free(ptr);
}
@@ -703,11 +703,9 @@ int CDECL MSVCRT_strncpy_s(char *dest, MSVCRT_size_t
numberOfElements,
if(!count)
return 0;
- if (!MSVCRT_CHECK_PMT(dest != NULL) || !MSVCRT_CHECK_PMT(src != NULL) ||
- !MSVCRT_CHECK_PMT(numberOfElements != 0)) {
- *_errno() = EINVAL;
- return EINVAL;
- }
+ if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL;
+ if (!MSVCRT_CHECK_PMT(src != NULL)) return MSVCRT_EINVAL;
+ if (!MSVCRT_CHECK_PMT(numberOfElements != 0)) return MSVCRT_EINVAL;
if(count!=MSVCRT__TRUNCATE && count<numberOfElements)
end = count;