-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strlen_bitwise.c
35 lines (32 loc) · 1.22 KB
/
ft_strlen_bitwise.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlen_bitwise.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lsauvage <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/02/06 16:34:07 by lsauvage #+# #+# */
/* Updated: 2018/05/11 16:32:55 by lsauvage ### ########.fr */
/* */
/* ************************************************************************** */
#include "./libft.h"
size_t ft_strlen_bitwise(const char *str)
{
size_t len;
unsigned long x;
len = 0;
while (1)
{
x = *(unsigned *)str;
if ((x & 0xFF) == 0)
return (len);
if ((x & 0xFF00) == 0)
return (len + 1);
if ((x & 0xFF0000) == 0)
return (len + 2);
if ((x & 0xFF000000) == 0)
return (len + 3);
str += 4;
len += 4;
}
}