The <mem.h> header file
This header file contains the following functions:
_memset memchr memcmp memcpy
memmove memset
and the following constants and predefined types:
NULL size_t
Functions
Copies a block of len bytes from src to dest.
memcpy copies a block of len bytes from src to dest.
If src and dest overlap,
the memcpy is ill-behaved (in such case, use memmove instead).
memcpy returns dest.
Searches the first len bytes of array str for character c.
memchr searches the first len bytes of the block pointed to by str for
character c. On success, memchr returns a pointer to the first occurrence of
c in str. Otherwise, it returns NULL.
Copies a block of len bytes from src to dest, with possibility
of overlaping of source and destination block.
memmove copies a block of len bytes from src to dest.
Even when the source and destination blocks overlap, bytes in the overlapping
locations are copied
correctly (in opposite to memcpy). memmove returns dest.
Compares two blocks, s1 and s2, for a length of exactly len bytes.
memcmp compares the first len bytes of the blocks s1 and s2 as unsigned chars.
Since it compares bytes as unsigned chars, memcmp returns a value
- < 0 if s1 is less than s2
- = 0 if s1 is the same as s2
- > 0 if s1 is greater than s2
For example, memcmp("\xFF","\x7F",1)
returns a value greater than 0. More precise,
the exact return value is the result of subtracting the first pair of values
that differ in the two blocks being compared based on them being signed
chars.
NOTE: This routine is declared as "short" although ANSI standard proposes "long". It is important,
because TIOS memcmp routine puts a garbage in higher half of D0 register!
Sets num bytes of buffer to byte c.
memset sets the first num bytes of the array buffer to the character c.
memset is faster than _memset, because it sets a
memory in a 4-byte chunks as long as possible. memset returns buffer.
Sets num bytes of buffer to byte c.
_memset is a slower (byte-by-byte) variant of
memset.
Constants and predefined types
size_t is a type proposed in ANSI C for defining size of strings and
memory blocks. It is defined here as
typedef unsigned long size_t;
NULL is a null-pointer value, defined as (void *) 0.