strncpy method

void strncpy(
  1. MemoryPointer<RType> dest,
  2. MemoryPointer<RType> src,
  3. int n
)

Implementation

void strncpy(MemoryPointer dest, MemoryPointer src, int n) {
  final srcLen = strlen(src);
  final copyLen = srcLen < n ? srcLen + 1 : n; // include NUL only if it fits
  dest.copyBytesFrom(src, copyLen);
  if (copyLen < n) dest.fillBytes(0, n - copyLen, copyLen); // pad rest with NUL
}