Add nullcpy()

Invented function to memcpy() with a specific size, but add a null terminator.
This commit is contained in:
apio 2022-12-18 16:31:02 +01:00
parent 0d65f188f0
commit eadca3d25b
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 9 additions and 0 deletions

View File

@ -12,4 +12,7 @@ extern "C"
usize wcslen(const wchar_t* str);
char* strdup(const char* str);
// Copies len bytes from src into dest and adds a null terminator.
void nullcpy(char* dest, const char* src, usize len);
}

View File

@ -65,4 +65,10 @@ extern "C"
return dest;
}
void nullcpy(char* dest, const char* src, usize len)
{
memcpy(dest, src, len);
dest[len] = 0;
}
}