# PetscMemcpy
Copies n bytes, beginning at location b, to the space beginning at location a. The two memory regions CANNOT overlap, use `PetscMemmove()` in that case. 
## Synopsis
```
static inline PetscErrorCode PetscMemcpy(void *a, const void *b, size_t n)
```
Not Collective


## Input Parameters

- ***b -*** pointer to initial memory space
- ***n -*** length (in bytes) of space to copy



## Output Parameter

- ***a -*** pointer to copy space





## Compile Option
`PETSC_PREFER_DCOPY_FOR_MEMCPY` will cause the BLAS dcopy() routine to be used
for memory copies on double precision values.
`PETSC_PREFER_COPY_FOR_MEMCPY` will cause C code to be used
for memory copies on double precision values.
`PETSC_PREFER_FORTRAN_FORMEMCPY` will cause Fortran code to be used
for memory copies on double precision values.


## Notes
Prefer `PetscArraycpy()`

This routine is analogous to `memcpy()`.

Not available from Fortran


## Developer Note
This is inlined for fastest performance


## See Also
 `PetscMemzero()`, `PetscMemcmp()`, `PetscArrayzero()`, `PetscArraycmp()`, `PetscArraycpy()`, `PetscMemmove()`, `PetscStrallocpy()`


## Level
intermediate

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/include/petscsys.h.html#PetscMemcpy">include/petscsys.h</A>

## Examples
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ksp/ksp/tutorials/ex74.c.html">src/ksp/ksp/tutorials/ex74.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex10.c.html">src/ts/tutorials/ex10.c.html</A><BR>
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/ts/tutorials/ex11.c.html">src/ts/tutorials/ex11.c.html</A><BR>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/include/petscsys.h)


[Index of all Sys routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
