2024-04-19 08:12:31 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2024-04-19 09:05:42 +02:00
|
|
|
#include "../../vmap.h"
|
2024-04-19 08:12:31 +02:00
|
|
|
|
|
|
|
int main() {
|
2024-04-19 09:05:42 +02:00
|
|
|
Memory* mem = memory_init(-1);
|
|
|
|
int pid = 12;
|
2024-04-19 08:12:31 +02:00
|
|
|
|
|
|
|
char* real1 = malloc(sizeof(char)*32);
|
|
|
|
real1[0] = 'h';
|
|
|
|
real1[1] = 'e';
|
|
|
|
real1[2] = 'l';
|
|
|
|
real1[3] = 'l';
|
|
|
|
real1[4] = 'o';
|
|
|
|
real1[5] = '!';
|
|
|
|
real1[6] = '\0';
|
|
|
|
|
2024-04-19 09:05:42 +02:00
|
|
|
char* data1 = my_malloc(mem, 32*sizeof(char), pid);
|
|
|
|
char* data2 = my_malloc(mem, 32*sizeof(char), pid);
|
2024-04-19 08:12:31 +02:00
|
|
|
|
2024-04-19 09:05:42 +02:00
|
|
|
vmap_copy_from_memory(mem, real1, data1, 8, pid);
|
2024-04-19 08:12:31 +02:00
|
|
|
|
2024-04-19 09:05:42 +02:00
|
|
|
my_copy(mem, data1, data2, 32*sizeof(char), pid);
|
2024-04-19 08:12:31 +02:00
|
|
|
|
|
|
|
char* real = malloc(sizeof(char)*32);
|
|
|
|
|
2024-04-19 09:05:42 +02:00
|
|
|
vmap_copy_to_memory(mem, data2, real, 7, pid);
|
2024-04-19 08:12:31 +02:00
|
|
|
|
2024-04-19 09:05:42 +02:00
|
|
|
if (strcmp(real, real1)) {
|
2024-04-19 08:12:31 +02:00
|
|
|
printf("%d\n", strcmp(real, real1));
|
|
|
|
fprintf(stderr, "copy test failed\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
free(real);
|
|
|
|
free(real1);
|
|
|
|
|
2024-04-19 09:05:42 +02:00
|
|
|
my_free(mem, data1, pid);
|
|
|
|
my_free(mem, data2, pid);
|
2024-04-19 08:12:31 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|