PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
memchr.c
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
11#define SYSCLIB_DISABLE_BUILTINS
12#include <sysclib.h>
13
14void *memchr(const void *s, int c, size_t n)
15{
16 if (!s || (s32)n <= 0)
17 {
18 return 0;
19 }
20 while (1)
21 {
22 n -= 1;
23 if (*(u8 *)s == (u8)c)
24 {
25 break;
26 }
27 s = (char *)s + 1;
28 if ((s32)n <= 0)
29 {
30 return 0;
31 }
32 }
33 return (void *)s;
34}