|
x-engine-c v0.2.13
The C engine for x-lang
|
Implementation of the C standard library replacements. More...
#include "x-stdlib.h"Functions | |
| int | x_lib_abs (int i) |
| void * | x_lib_memcpy (void *p_dest, const void *p_src, size_t size) |
| void * | x_lib_memset (void *p_dest, int byte, size_t size) |
| char * | x_lib_strchr (const char *p_str, int c) |
| int | x_lib_strcmp (const char *p_str1, const char *p_str2) |
| size_t | x_lib_strlen (const char *p_str) |
| int | x_lib_strncmp (const char *p_str1, const char *p_str2, size_t n) |
| char * | x_lib_strndup (const char *p_str, size_t size) |
Implementation of the C standard library replacements.
The C standard defines the behaviour here, not us (see x-stdlib.h for the charter). Comparison functions compare bytes as unsigned char (C99 7.24.4) regardless of the platform's plain-char signedness, and strchr converts c to char before comparing (C99 7.24.5.2) – both exactly as the standard specifies, so the freestanding path and an X_USE_STDLIB build agree byte-for-byte.
., .,
{O,O}
( )
" "
| int x_lib_abs | ( | int | i | ) |
Compute the absolute value of an integer.
| i | The integer value. |
i. | void * x_lib_memcpy | ( | void * | p_dest, |
| const void * | p_src, | ||
| size_t | size | ||
| ) |
Copy bytes from a source buffer to a destination buffer.
| p_dest | Pointer to the destination buffer. |
| p_src | Pointer to the source buffer. |
| size | Number of bytes to copy. |
p_dest. | void * x_lib_memset | ( | void * | p_dest, |
| int | byte, | ||
| size_t | size | ||
| ) |
Fill a memory region with a constant byte.
| p_dest | Pointer to the destination buffer. |
| byte | The byte value to fill with. |
| size | Number of bytes to set. |
p_dest. | char * x_lib_strchr | ( | const char * | p_str, |
| int | c | ||
| ) |
Locate the first occurrence of a character in a string.
c is converted to char before comparing, and the terminating NUL is part of the string (C99 7.24.5.2): searching for '\0' returns the terminator.
| p_str | The string to search. |
| c | The character to find (as an int). |
| int x_lib_strcmp | ( | const char * | p_str1, |
| const char * | p_str2 | ||
| ) |
Compare two null-terminated strings.
Bytes compare as unsigned char (C99 7.24.4), independent of the platform's plain-char signedness.
| p_str1 | First string. |
| p_str2 | Second string. |
| size_t x_lib_strlen | ( | const char * | p_str | ) |
Calculate the length of a null-terminated string.
| p_str | The string to measure. |
| int x_lib_strncmp | ( | const char * | p_str1, |
| const char * | p_str2, | ||
| size_t | n | ||
| ) |
Compare two strings up to a maximum of n characters.
Bytes compare as unsigned char (C99 7.24.4); n == 0 compares nothing and returns 0.
| p_str1 | First string. |
| p_str2 | Second string. |
| n | Maximum number of characters to compare. |
| char * x_lib_strndup | ( | const char * | p_str, |
| size_t | size | ||
| ) |
Duplicate at most size characters of a string.
The copy stops at the first NUL or after size characters, whichever comes first, and is always NUL-terminated; at most size source bytes are read.
| p_str | The source string. |
| size | Maximum number of characters to copy. |