7memcpy (
void *dst_,
const void *src_,
size_t size)
9 unsigned char *dst = dst_;
10 const unsigned char *src = src_;
24memmove (
void *dst_,
const void *src_,
size_t size)
26 unsigned char *dst = dst_;
27 const unsigned char *src = src_;
53memcmp (
const void *a_,
const void *b_,
size_t size)
55 const unsigned char *a = a_;
56 const unsigned char *b = b_;
61 for (; size-- > 0; a++, b++)
63 return *a > *b ? +1 : -1;
73strcmp (
const char *a_,
const char *b_)
75 const unsigned char *a = (
const unsigned char *) a_;
76 const unsigned char *b = (
const unsigned char *) b_;
81 while (*a !=
'\0' && *a == *b)
87 return *a < *b ? -1 : *a > *b;
94memchr (
const void *block_,
int ch_,
size_t size)
96 const unsigned char *
block = block_;
97 unsigned char ch = ch_;
101 for (; size-- > 0;
block++)
103 return (
void *)
block;
121 return (
char *) string;
122 else if (*
string ==
'\0')
135 for (length = 0;
string[length] !=
'\0'; length++)
147 for (; *
string !=
'\0';
string++)
149 return (
char *) string;
159 const char *p =
NULL;
161 for (; *
string !=
'\0';
string++)
170strspn (
const char *
string,
const char *skip)
174 for (length = 0;
string[length] !=
'\0'; length++)
184strstr (
const char *haystack,
const char *needle)
186 size_t haystack_len =
strlen (haystack);
187 size_t needle_len =
strlen (needle);
189 if (haystack_len >= needle_len)
193 for (i = 0; i <= haystack_len - needle_len; i++)
194 if (!
memcmp (haystack + i, needle, needle_len))
195 return (
char *) haystack + i;
235strtok_r (
char *
s,
const char *delimiters,
char **save_ptr)
281 unsigned char *dst = dst_;
299 for (p =
string; *p !=
'\0'; p++)
311 for (length = 0;
string[length] !=
'\0' && length < maxlen; length++)
326strlcpy (
char *dst,
const char *src,
size_t size)
336 size_t dst_len = size - 1;
337 if (src_len < dst_len)
339 memcpy (dst, src, dst_len);
356strlcat (
char *dst,
const char *src,
size_t size)
358 size_t src_len, dst_len;
365 if (size > 0 && dst_len < size)
367 size_t copy_cnt = size - dst_len - 1;
368 if (src_len < copy_cnt)
370 memcpy (dst + dst_len, src, copy_cnt);
371 dst[dst_len + copy_cnt] =
'\0';
373 return src_len + dst_len;
#define ASSERT(CONDITION)
This is outside the header guard so that debug.h may be included multiple times with different settin...
static uint8_t s[256]
RC4-based pseudo-random number generator (PRNG).
size_t strnlen(const char *string, size_t maxlen)
If STRING is less than MAXLEN characters in length, returns its actual length.
size_t strlcat(char *dst, const char *src, size_t size)
Concatenates string SRC to DST.
char * strchr(const char *string, int c_)
Finds and returns the first occurrence of C in STRING, or a null pointer if C does not appear in STRI...
int memcmp(const void *a_, const void *b_, size_t size)
Find the first differing byte in the two blocks of SIZE bytes at A and B.
size_t strspn(const char *string, const char *skip)
Returns the length of the initial substring of STRING that consists of characters in SKIP.
size_t strlen(const char *string)
Returns the length of STRING.
void * memset(void *dst_, int value, size_t size)
Sets the SIZE bytes in DST to VALUE.
size_t strlcpy(char *dst, const char *src, size_t size)
Copies string SRC to DST.
size_t strcspn(const char *string, const char *stop)
Returns the length of the initial substring of STRING that consists of characters that are not in STO...
void * memmove(void *dst_, const void *src_, size_t size)
Copies SIZE bytes from SRC to DST, which are allowed to overlap.
void * memcpy(void *dst_, const void *src_, size_t size)
Copies SIZE bytes from SRC to DST, which must not overlap.
char * strtok_r(char *s, const char *delimiters, char **save_ptr)
Breaks a string into tokens separated by DELIMITERS.
char * strrchr(const char *string, int c_)
Returns a pointer to the last occurrence of C in STRING.
char * strpbrk(const char *string, const char *stop)
Returns a pointer to the first character in STRING that is also in STOP.
char * strstr(const char *haystack, const char *needle)
Returns a pointer to the first occurrence of NEEDLE within HAYSTACK.
void * memchr(const void *block_, int ch_, size_t size)
Returns a pointer to the first occurrence of CH in the first SIZE bytes starting at BLOCK.
int strcmp(const char *a_, const char *b_)
Finds the first differing characters in strings A and B.