mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-04 22:49:32 +03:00
use pragma warning only on msvc (issue #291)
This commit is contained in:
parent
d73d6beb71
commit
032eb2a75a
3 changed files with 15 additions and 8 deletions
|
@ -20,6 +20,10 @@ terms of the MIT license. A copy of the license can be found in the file
|
||||||
#include <string.h> // memcpy
|
#include <string.h> // memcpy
|
||||||
#include <stdlib.h> // getenv
|
#include <stdlib.h> // getenv
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable:4996) // getenv _wgetenv
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef EINVAL
|
#ifndef EINVAL
|
||||||
#define EINVAL 22
|
#define EINVAL 22
|
||||||
#endif
|
#endif
|
||||||
|
@ -111,8 +115,7 @@ mi_decl_restrict unsigned char* mi_mbsdup(const unsigned char* s) mi_attr_noexc
|
||||||
int mi_dupenv_s(char** buf, size_t* size, const char* name) mi_attr_noexcept {
|
int mi_dupenv_s(char** buf, size_t* size, const char* name) mi_attr_noexcept {
|
||||||
if (buf==NULL || name==NULL) return EINVAL;
|
if (buf==NULL || name==NULL) return EINVAL;
|
||||||
if (size != NULL) *size = 0;
|
if (size != NULL) *size = 0;
|
||||||
#pragma warning(suppress:4996)
|
char* p = getenv(name); // mscver warning 4996
|
||||||
char* p = getenv(name);
|
|
||||||
if (p==NULL) {
|
if (p==NULL) {
|
||||||
*buf = NULL;
|
*buf = NULL;
|
||||||
}
|
}
|
||||||
|
@ -132,8 +135,7 @@ int mi_wdupenv_s(unsigned short** buf, size_t* size, const unsigned short* name)
|
||||||
*buf = NULL;
|
*buf = NULL;
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
#else
|
#else
|
||||||
#pragma warning(suppress:4996)
|
unsigned short* p = (unsigned short*)_wgetenv((const wchar_t*)name); // msvc warning 4996
|
||||||
unsigned short* p = (unsigned short*)_wgetenv((const wchar_t*)name);
|
|
||||||
if (p==NULL) {
|
if (p==NULL) {
|
||||||
*buf = NULL;
|
*buf = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,11 @@ terms of the MIT license. A copy of the license can be found in the file
|
||||||
#include <ctype.h> // toupper
|
#include <ctype.h> // toupper
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable:4996) // strncpy, strncat
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static uintptr_t mi_max_error_count = 16; // stop outputting errors after this
|
static uintptr_t mi_max_error_count = 16; // stop outputting errors after this
|
||||||
|
|
||||||
static void mi_add_stderr_output();
|
static void mi_add_stderr_output();
|
||||||
|
@ -215,7 +220,6 @@ static void mi_out_buf_stderr(const char* msg, void* arg) {
|
||||||
|
|
||||||
// Should be atomic but gives errors on many platforms as generally we cannot cast a function pointer to a uintptr_t.
|
// Should be atomic but gives errors on many platforms as generally we cannot cast a function pointer to a uintptr_t.
|
||||||
// For now, don't register output from multiple threads.
|
// For now, don't register output from multiple threads.
|
||||||
#pragma warning(suppress:4180)
|
|
||||||
static mi_output_fun* volatile mi_out_default; // = NULL
|
static mi_output_fun* volatile mi_out_default; // = NULL
|
||||||
static _Atomic(void*) mi_out_arg; // = NULL
|
static _Atomic(void*) mi_out_arg; // = NULL
|
||||||
|
|
||||||
|
@ -389,13 +393,11 @@ void _mi_error_message(int err, const char* fmt, ...) {
|
||||||
|
|
||||||
static void mi_strlcpy(char* dest, const char* src, size_t dest_size) {
|
static void mi_strlcpy(char* dest, const char* src, size_t dest_size) {
|
||||||
dest[0] = 0;
|
dest[0] = 0;
|
||||||
#pragma warning(suppress:4996)
|
|
||||||
strncpy(dest, src, dest_size - 1);
|
strncpy(dest, src, dest_size - 1);
|
||||||
dest[dest_size - 1] = 0;
|
dest[dest_size - 1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mi_strlcat(char* dest, const char* src, size_t dest_size) {
|
static void mi_strlcat(char* dest, const char* src, size_t dest_size) {
|
||||||
#pragma warning(suppress:4996)
|
|
||||||
strncat(dest, src, dest_size - 1);
|
strncat(dest, src, dest_size - 1);
|
||||||
dest[dest_size - 1] = 0;
|
dest[dest_size - 1] = 0;
|
||||||
}
|
}
|
||||||
|
|
5
src/os.c
5
src/os.c
|
@ -22,6 +22,10 @@ terms of the MIT license. A copy of the license can be found in the file
|
||||||
|
|
||||||
#include <string.h> // strerror
|
#include <string.h> // strerror
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable:4996) // strerror
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
@ -233,7 +237,6 @@ static bool mi_os_mem_free(void* addr, size_t size, bool was_committed, mi_stats
|
||||||
if (was_committed) _mi_stat_decrease(&stats->committed, size);
|
if (was_committed) _mi_stat_decrease(&stats->committed, size);
|
||||||
_mi_stat_decrease(&stats->reserved, size);
|
_mi_stat_decrease(&stats->reserved, size);
|
||||||
if (err) {
|
if (err) {
|
||||||
#pragma warning(suppress:4996)
|
|
||||||
_mi_warning_message("munmap failed: %s, addr 0x%8li, size %lu\n", strerror(errno), (size_t)addr, size);
|
_mi_warning_message("munmap failed: %s, addr 0x%8li, size %lu\n", strerror(errno), (size_t)addr, size);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue