aboutsummaryrefslogtreecommitdiff
path: root/src/mem/ft_memset.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem/ft_memset.c')
-rw-r--r--src/mem/ft_memset.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/mem/ft_memset.c b/src/mem/ft_memset.c
index 7963fd0..4ede5f3 100644
--- a/src/mem/ft_memset.c
+++ b/src/mem/ft_memset.c
@@ -6,26 +6,26 @@
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/07 10:01:23 by cacharle #+# #+# */
-/* Updated: 2019/11/20 23:22:51 by cacharle ### ########.fr */
+/* Updated: 2019/11/21 18:40:59 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
-#define BUF_TYPE long int
-
void *ft_memset(void *s, int c, size_t n)
{
- BUF_TYPE buf;
+ long int buf;
+ long int *long_s;
c = (unsigned char)c;
while (n % 8 > 0)
- *((t_byte*)s + --n) = (t_byte)c;
+ *((t_byte*)s + --n) = c;
+ buf = (long int)c | (long int)c << 8 | (long int)c << 16
+ | (long int)c << 24 | (long int)c << 32 | (long int)c << 40
+ | (long int)c << 48 | (long int)c << 56;
n /= 8;
- buf = (BUF_TYPE)c | (BUF_TYPE)c << 8 | (BUF_TYPE)c << 16
- | (BUF_TYPE)c << 24 | (BUF_TYPE)c << 32 | (BUF_TYPE)c << 40
- | (BUF_TYPE)c << 48 | (BUF_TYPE)c << 56;
+ long_s = s;
while (n > 0)
- *((BUF_TYPE*)s + --n) = buf;
+ long_s[--n] = buf;
return (s);
}