The buffer-manipulation routines are useful for working with areas of memory on a byte-by-byte basis. A “buffer” is an array of bytes, similar to a character string. However, unlike strings, buffers are not usually terminated with a null character ('\0') and can contain non-ASCII data. Therefore, the buffer-manipulation routines always take a length or count argument. Function declarations for the buffer-manipulation routines are given in the include files MEMORY.H and STRING.H, except for the _swab function, which appears in STDLIB.H.
Routines beginning with _f are model independent; the _f stands for far. These routines are useful in writing mixed-model programs because they can be called from any program, regardless of the memory model being used.
Routine | Use |
_memccpy, _fmemccpy | Copy characters from one buffer to another until a given character or a given number of characters has been copied |
memchr, _fmemchr | Return a pointer to the first occurrence, within a specified number of characters, of a given character in the buffer |
memcmp, _fmemcmp | Compare a specified number of characters from two buffers |
memcpy, _fmemcpy | Copy a specified number of characters from one buffer to another |
_memicmp, _fmemicmp | Compare a specified number of characters from two buffers without regard to the case of the letters (uppercase and lowercase treated as equivalent) |
memmove, _fmemmove | Copy a specified number of characters from one buffer to another |
memset, _fmemset | Use a given character to initialize a specified number of bytes in the buffer |
_swab | Swaps bytes of data and stores them at the specified location |
When the source and target areas overlap, only the memmove and _fmemmove functions are guaranteed to copy the full source properly. (The memcpy and _fmemcpy routines do not always copy the full source in such cases.)