Skip to content

Commit

Permalink
make c_memmove return the destination, like in the C standard library.
Browse files Browse the repository at this point in the history
this is mostly cosmetic since the return value is not used in the only call site of c_memmove (bignum_serialize)
  • Loading branch information
smx-smx committed Aug 4, 2024
1 parent 2f9fcf4 commit b5839a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion xzre.h
Original file line number Diff line number Diff line change
Expand Up @@ -3935,7 +3935,7 @@ extern ssize_t c_strnlen(
* @param src source buffer
* @param cnt number of bytes to copy
*/
extern void c_memmove(
extern void* c_memmove(
char *dest,
char *src,
size_t cnt
Expand Down
8 changes: 4 additions & 4 deletions xzre_code/c_memmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
**/
#include "xzre.h"

void c_memmove(char *dest, char *src, size_t cnt) {
void *c_memmove(char *dest, char *src, size_t cnt) {
if ((src < dest) && (dest < (src + cnt))) {
size_t curr = cnt - 1;
if (cnt != 0) {
do {
*(dest + curr) = *(src + curr);
--curr;
} while (curr != -1);
return;
return dest;
}
} else {
if (cnt == 0)
return;
return dest;
size_t curr = 0;
do {
*(dest + curr) = *(src + curr);
++curr;
} while (cnt != curr);
}
return;
return dest;
}

0 comments on commit b5839a2

Please sign in to comment.