Skip to content

Commit 8d0a5ca

Browse files
authored
Merge pull request #336 from lplewa/crt
add _CRT_SECURE_NO_WARNINGS definition
2 parents 6b92f14 + 683a26e commit 8d0a5ca

File tree

5 files changed

+3
-19
lines changed

5 files changed

+3
-19
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ install(
117117
if(WINDOWS)
118118
# set PATH to DLLs on Windows
119119
set(DLL_PATH_LIST "PATH=path_list_append:../bin/$<CONFIG>")
120+
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
120121
endif()
121122

122123
if(UMF_BUILD_OS_MEMORY_PROVIDER AND (LINUX OR WINDOWS))

examples/basic/basic.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#include <stdio.h>
1414
#include <string.h>
1515

16-
#include "utils_common.h"
17-
1816
int main(void) {
1917
// A result object for storing UMF API result status
2018
umf_result_t res;
@@ -51,7 +49,7 @@ int main(void) {
5149

5250
// Write to the allocated memory
5351
memset(ptr_provider, '\0', alloc_size);
54-
util_strncpy(ptr_provider, alloc_size, strSource, strlen(strSource) + 1);
52+
strncpy(ptr_provider, strSource, alloc_size);
5553
printf("%s %p with the memory provider at %p\n", (char *)ptr_provider,
5654
(void *)ptr_provider, (void *)provider);
5755

@@ -87,7 +85,7 @@ int main(void) {
8785
}
8886

8987
// Write a string to allocated memory
90-
util_strncpy(ptr, alloc_size, strSource, strlen(strSource) + 1);
88+
strncpy(ptr, strSource, alloc_size);
9189
printf("%s %p\n", ptr, (void *)ptr);
9290

9391
// Retrieve a memory pool from a pointer, available with memory tracking

src/utils/utils_common.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ int util_is_running_in_proxy_lib(void);
6666

6767
size_t util_get_page_size(void);
6868

69-
char *util_strncpy(char *dest, size_t destSize, const char *src, size_t n);
70-
7169
// align a pointer and a size
7270
void util_align_ptr_size(void **ptr, size_t *size, size_t alignment);
7371

src/utils/utils_posix_common.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,3 @@ size_t util_get_page_size(void) {
5050
util_init_once(&Page_size_is_initialized, _util_get_page_size);
5151
return Page_size;
5252
}
53-
54-
char *util_strncpy(char *dest, size_t destSize, const char *src, size_t n) {
55-
(void)destSize; // unused
56-
return strncpy(dest, src, n);
57-
}

src/utils/utils_windows_common.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,3 @@ size_t util_get_page_size(void) {
4646
util_init_once(&Page_size_is_initialized, _util_get_page_size);
4747
return Page_size;
4848
}
49-
50-
char *util_strncpy(char *dest, size_t destSize, const char *src, size_t n) {
51-
if (strncpy_s(dest, destSize, src, n)) {
52-
return NULL;
53-
}
54-
55-
return dest;
56-
}

0 commit comments

Comments
 (0)