Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. static UINT32 safe_buffer_copy(const void *source, UINT32 sourceoffs, UINT32 sourcelen, void *dest, UINT32 destoffs, UINT32 destlen)
  2. {
  3.     int sourceavail = sourcelen - sourceoffs;
  4.     int destavail = destlen - destoffs;
  5.     int bytes_to_copy = sourceavail < destavail ? sourceavail : destavail;
  6.     if (bytes_to_copy > 0)
  7.         memcpy((UINT8 *)dest + destoffs, (const UINT8 *)source + sourceoffs, bytes_to_copy);
  8.     return bytes_to_copy > 0 ? bytes_to_copy : 0;
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement