On 19.08.2021 15:10, Nigel Croxon wrote:
+ memset(ve->name, '\0', sizeof(ve->name)); + if (name) { + int l = strlen(ve->name); + if (l > 16) + l = 16; + memcpy(ve->name, name, l); + }
What about: if (name) /* * Name might not be null terminated. */ strncpy(ve->name, name, sizeof(ve->name)); else memset(ve->name, '\0', sizeof(ve->name)); If size is less than sizeof(ve->name) then strncpy will automatically fill rest with "\0". Mariusz