|
13 | 13 | #include <stdio.h>
|
14 | 14 | #include <string.h>
|
15 | 15 |
|
| 16 | +#include "utils_common.h" |
| 17 | + |
16 | 18 | int main(void) {
|
17 | 19 | // A result object for storing UMF API result status
|
18 | 20 | umf_result_t res;
|
@@ -45,9 +47,11 @@ int main(void) {
|
45 | 47 | goto memory_provider_destroy;
|
46 | 48 | }
|
47 | 49 |
|
| 50 | + const char *strSource = "Allocated memory at"; |
| 51 | + |
48 | 52 | // Write to the allocated memory
|
49 | 53 | memset(ptr_provider, '\0', alloc_size);
|
50 |
| - strcpy(ptr_provider, "Allocated memory at"); |
| 54 | + util_strncpy(ptr_provider, alloc_size, strSource, strlen(strSource) + 1); |
51 | 55 | printf("%s %p with the memory provider at %p\n", (char *)ptr_provider,
|
52 | 56 | (void *)ptr_provider, (void *)provider);
|
53 | 57 |
|
@@ -83,7 +87,7 @@ int main(void) {
|
83 | 87 | }
|
84 | 88 |
|
85 | 89 | // Write a string to allocated memory
|
86 |
| - strcpy(ptr, "Allocated memory at"); |
| 90 | + util_strncpy(ptr, alloc_size, strSource, strlen(strSource) + 1); |
87 | 91 | printf("%s %p\n", ptr, (void *)ptr);
|
88 | 92 |
|
89 | 93 | // Retrieve a memory pool from a pointer, available with memory tracking
|
|
0 commit comments