The <mem.h> Header File

Routines for manipulation of memory blocks

Functions

_memset
Sets num bytes of buffer to byte c.
memchr
Searches the first len bytes of array str for character c.
memcmp
Compares two blocks of signed chars.
memcpy
Copies a block of len bytes from src to dest.
memmove
Copies a block of len bytes from src to dest, with possibility of overlaping of source and destination block.
memset
Sets num bytes of buffer to byte c.
memucmp
Compares two blocks of unsigned chars.

Constants

NULL
A null-pointer value.

Predefined Types

size_t
A type to define sizes of strings and memory blocks.

See also: alloc.h


_memset

void *_memset (void *buffer, short c, unsigned long num);

Sets num bytes of buffer to byte c.

_memset is a slower (byte-by-byte) variant of memset.


memchr

void *memchr (const void *str, short c, unsigned long len);

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.


memcmp

short memcmp (const void *s1, const void *s2, unsigned long len);

Compares two blocks of signed chars.

memcmp compares the first len bytes of the blocks s1 and s2 as signed chars. Since it compares bytes as signed chars, memcmp returns a value

For example, memcmp("\xFF","\x7F",1) returns a value greater than 0. More precisely, 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 the ANSI standard proposes "long". This is important, because the TIOS memcmp routine puts garbage in the higher half of the d0 register.

See also: memucmp


memcpy

void *memcpy (void *dest, const void *src, unsigned long len);

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.


memmove

void *memmove (void *dest, const void *src, unsigned long len);

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.


memset

void *memset (void *buffer, short c, unsigned long num);

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.


memucmp

AMS 2.00 or higher

short memucmp (const void *s1, const void *s1, unsigned long len);

Compares two blocks of unsigned chars.

memucmp acts like memcmp, but treats s1 and s2 as pointers to unsigned chars.

See also: memcmp


Return to the main index