Skip to content

Commit 9ea6ac9

Browse files
committed
Enable base example on Windows
Replace strcpy() with util_strncpy() in the base example. Signed-off-by: Lukasz Dorau <[email protected]>
1 parent a17c003 commit 9ea6ac9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ if(UMF_BUILD_OS_MEMORY_PROVIDER
1111
LIBS umf
1212
scalable_pool)
1313
target_include_directories(${EXAMPLE_NAME} PRIVATE
14+
${UMF_CMAKE_SOURCE_DIR}/src/utils
1415
${UMF_CMAKE_SOURCE_DIR}/include)
1516

1617
add_test(NAME ${EXAMPLE_NAME}

examples/basic/basic.c

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

16+
#include "utils_common.h"
17+
1618
int main(void) {
1719
// A result object for storing UMF API result status
1820
umf_result_t res;
@@ -45,9 +47,11 @@ int main(void) {
4547
goto memory_provider_destroy;
4648
}
4749

50+
const char *strSource = "Allocated memory at";
51+
4852
// Write to the allocated memory
4953
memset(ptr_provider, '\0', alloc_size);
50-
strcpy(ptr_provider, "Allocated memory at");
54+
util_strncpy(ptr_provider, alloc_size, strSource, strlen(strSource) + 1);
5155
printf("%s %p with the memory provider at %p\n", (char *)ptr_provider,
5256
(void *)ptr_provider, (void *)provider);
5357

@@ -83,7 +87,7 @@ int main(void) {
8387
}
8488

8589
// Write a string to allocated memory
86-
strcpy(ptr, "Allocated memory at");
90+
util_strncpy(ptr, alloc_size, strSource, strlen(strSource) + 1);
8791
printf("%s %p\n", ptr, (void *)ptr);
8892

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

0 commit comments

Comments
 (0)