diff options
| author | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:08:27 +0200 |
|---|---|---|
| committer | Martial Simon <msimon_fr@hotmail.com> | 2025-09-15 01:08:27 +0200 |
| commit | c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (patch) | |
| tree | 3e4f42f93c7ae89a364e4d51fff6e5cec4e55fa9 /rushs/tinyprintf/my_memmove | |
add: graphs et rushs
Diffstat (limited to 'rushs/tinyprintf/my_memmove')
| -rw-r--r-- | rushs/tinyprintf/my_memmove/my_memmove.c | 23 | ||||
| -rw-r--r-- | rushs/tinyprintf/my_memmove/my_memmove.h | 8 |
2 files changed, 31 insertions, 0 deletions
diff --git a/rushs/tinyprintf/my_memmove/my_memmove.c b/rushs/tinyprintf/my_memmove/my_memmove.c new file mode 100644 index 0000000..bb360a5 --- /dev/null +++ b/rushs/tinyprintf/my_memmove/my_memmove.c @@ -0,0 +1,23 @@ +#include "my_memmove.h" + +void *my_memmove(void *dest, const void *src, size_t n) +{ + char *d = dest; + const char *s = src; + if (dest > src) // reverse array + { + size_t l = n; + for (; l > 0; l--) + { + d[l - 1] = s[l - 1]; + } + } + else + { + for (size_t i = 0; i < n; i++) + { + d[i] = s[i]; + } + } + return dest; +} diff --git a/rushs/tinyprintf/my_memmove/my_memmove.h b/rushs/tinyprintf/my_memmove/my_memmove.h new file mode 100644 index 0000000..cb253b7 --- /dev/null +++ b/rushs/tinyprintf/my_memmove/my_memmove.h @@ -0,0 +1,8 @@ +#ifndef MY_MEMMOVE_H +#define MY_MEMMOVE_H + +#include <stddef.h> + +void *my_memmove(void *dest, const void *src, size_t n); + +#endif /* ! MY_MEMMOVE_H */ |
