memcpy Interface
Interface Description
Optimized memcpy interface.
Interface Format
void *memcpy(void *dest, const void *src, size_t n);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
dest |
Pointer array |
Destination array that stores the copied content. |
Input/Output |
src |
Pointer array |
Source array that stores the copied content. |
Input |
n |
Integer |
Number of bytes to be copied. |
Input |
Dependency
None
Example
- Write memcpy test code.
- Create a test.c file.
vi test.c
- Press i to enter the insert mode and add the following test code to the file:
#include <stdio.h> #include <stdint.h> #include <string.h> #define MAX_LENGTH 4096 int main(int argc, char **argv) { uint8_t src[MAX_LENGTH] = {0}; uint8_t dest[MAX_LENGTH] = {0}; for (size_t i = 0; i < MAX_LENGTH; ++i) { src[i] = i; } memcpy(dest, src, MAX_LENGTH); if (memcmp(dest, src, MAX_LENGTH) == 0) { printf("memcpy succ!!\r\n"); } else { printf("memcpy fail!!\r\n"); } return 0; } - Press Esc to exit the insert mode. Type :wq! and press Enter to save and exit the file.
- Create a test.c file.
- Compile the test.c file into an executable file test.
gcc test.c -o test
- Run the test executable file.
LD_PRELOAD=/usr/lib64/libksal_libc.so ./test
The command output is as follows:memcpy succ!!
Parent topic: KSAL Development Reference