mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-06 19:38:41 +03:00
add nodiscard annotations to fix warnings in msvc
This commit is contained in:
parent
e1b27a0fc2
commit
5b172280b0
4 changed files with 74 additions and 39 deletions
|
@ -57,7 +57,9 @@ int main(void) {
|
|||
// ---------------------------------------------------
|
||||
|
||||
CHECK_BODY("malloc-zero",{
|
||||
void* p = mi_malloc(0); mi_free(p);
|
||||
void* p = mi_malloc(0);
|
||||
result = (p != NULL);
|
||||
mi_free(p);
|
||||
});
|
||||
CHECK_BODY("malloc-nomem1",{
|
||||
result = (mi_malloc((size_t)PTRDIFF_MAX + (size_t)1) == NULL);
|
||||
|
@ -174,6 +176,21 @@ int main(void) {
|
|||
result = ok;
|
||||
});
|
||||
|
||||
// ---------------------------------------------------
|
||||
// Reallocation
|
||||
// ---------------------------------------------------
|
||||
CHECK_BODYX("realloc-null1") {
|
||||
void* p = mi_realloc(NULL,4);
|
||||
result = (p != NULL);
|
||||
mi_free(p);
|
||||
};
|
||||
|
||||
CHECK_BODYX("realloc-null2") {
|
||||
void* p = mi_realloc(NULL,0); // <https://en.cppreference.com/w/c/memory/realloc> "If ptr is NULL, the behavior is the same as calling malloc(new_size)."
|
||||
result = (p != NULL);
|
||||
mi_free(p);
|
||||
};
|
||||
|
||||
// ---------------------------------------------------
|
||||
// Heaps
|
||||
// ---------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue