Started from buttom go to the sky
This commit is contained in:
parent
96215449bd
commit
f811e55dea
4781 changed files with 10121 additions and 1743 deletions
38
stdme/src/mem/mem_find_bytes.c
Normal file
38
stdme/src/mem/mem_find_bytes.c
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* mem_find_bytes.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/06 11:16:02 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/01/06 17:14:23 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "me/mem/mem_find_bytes.h"
|
||||
#include "stdio.h"
|
||||
|
||||
void *mem_find_bytes(void *buf, t_u8 *find, t_usize find_len, t_usize count)
|
||||
{
|
||||
t_usize i;
|
||||
t_usize j;
|
||||
t_u8 *buf_bytes;
|
||||
|
||||
i = 0;
|
||||
buf_bytes = (t_u8 *)buf;
|
||||
while (i < count)
|
||||
{
|
||||
j = 0;
|
||||
while (j < find_len && i + j < count)
|
||||
{
|
||||
if (buf_bytes[i + j] != find[j])
|
||||
break ;
|
||||
j++;
|
||||
}
|
||||
if (j == find_len)
|
||||
return ((void *)&buf_bytes[i]);
|
||||
i++;
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue